2021-07-07 00:00:00 +10:00
From 6b04ee644062be0dd1766d612a462765605a986d Mon Sep 17 00:00:00 2001
2014-04-13 14:41:33 +10:00
From: md_5 <git@md-5.net>
Date: Sun, 13 Apr 2014 14:41:23 +1000
Subject: [PATCH] Use Offline Player Data Once if Required.
If we are online mode and the only copy of player data we can find is the player's offline mode data, we will attempt a once off conversion by reading this data and then renaming the file so it won't be used again.
2021-03-16 09:00:00 +11:00
diff --git a/src/main/java/net/minecraft/world/level/storage/WorldNBTStorage.java b/src/main/java/net/minecraft/world/level/storage/WorldNBTStorage.java
2021-06-11 15:00:00 +10:00
index cc8c40cfd..75f3ddb40 100644
2021-03-16 09:00:00 +11:00
--- a/src/main/java/net/minecraft/world/level/storage/WorldNBTStorage.java
+++ b/src/main/java/net/minecraft/world/level/storage/WorldNBTStorage.java
@@ -53,10 +53,28 @@ public class WorldNBTStorage {
2014-04-13 14:41:33 +10:00
try {
2019-04-23 12:00:00 +10:00
File file = new File(this.playerDir, entityhuman.getUniqueIDString() + ".dat");
2014-04-13 14:41:33 +10:00
+ // Spigot Start
+ boolean usingWrongFile = false;
2014-11-26 08:27:08 +11:00
+ if ( !file.exists() )
2014-04-13 14:41:33 +10:00
+ {
2020-06-25 10:00:00 +10:00
+ file = new File( this.playerDir, java.util.UUID.nameUUIDFromBytes( ( "OfflinePlayer:" + entityhuman.getName() ).getBytes( "UTF-8" ) ).toString() + ".dat");
2014-11-26 08:27:08 +11:00
+ if ( file.exists() )
2014-04-13 14:41:33 +10:00
+ {
+ usingWrongFile = true;
+ org.bukkit.Bukkit.getServer().getLogger().warning( "Using offline mode UUID file for player " + entityhuman.getName() + " as it is the only copy we can find." );
+ }
+ }
+ // Spigot End
2014-11-26 08:27:08 +11:00
if (file.exists() && file.isFile()) {
2020-08-12 07:00:00 +10:00
nbttagcompound = NBTCompressedStreamTools.a(file);
2014-04-13 14:41:33 +10:00
}
+ // Spigot Start
+ if ( usingWrongFile )
+ {
2014-11-26 08:27:08 +11:00
+ file.renameTo( new File( file.getPath() + ".offline-read" ) );
2014-04-13 14:41:33 +10:00
+ }
+ // Spigot End
} catch (Exception exception) {
2019-04-25 12:00:00 +10:00
WorldNBTStorage.LOGGER.warn("Failed to load player data for {}", entityhuman.getDisplayName().getString());
2014-04-13 14:41:33 +10:00
}
--
2020-05-09 18:48:11 +10:00
2.25.1
2014-04-13 14:41:33 +10:00