2019-01-05 16:21:07 +11:00
From cbb2f141cd0ad0901406df3d78a2c93f5cc2d264 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.
diff --git a/src/main/java/net/minecraft/server/WorldNBTStorage.java b/src/main/java/net/minecraft/server/WorldNBTStorage.java
2018-12-13 11:00:00 +11:00
index ba8052615..2e1abad4a 100644
2014-04-13 14:41:33 +10:00
--- a/src/main/java/net/minecraft/server/WorldNBTStorage.java
+++ b/src/main/java/net/minecraft/server/WorldNBTStorage.java
2018-08-26 12:00:00 +10:00
@@ -164,10 +164,28 @@ public class WorldNBTStorage implements IDataManager, IPlayerFileData {
2014-04-13 14:41:33 +10:00
try {
2018-07-15 10:00:00 +10:00
File file = new File(this.playerDir, entityhuman.bu() + ".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
+ {
2014-11-26 08:27:08 +11:00
+ file = new File( this.playerDir, UUID.nameUUIDFromBytes( ( "OfflinePlayer:" + entityhuman.getName() ).getBytes( "UTF-8" ) ).toString() + ".dat");
+ 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()) {
nbttagcompound = NBTCompressedStreamTools.a((InputStream) (new FileInputStream(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) {
2018-07-15 10:00:00 +10:00
WorldNBTStorage.b.warn("Failed to load player data for {}", entityhuman.getDisplayName().getString());
2014-04-13 14:41:33 +10:00
}
--
2018-11-14 14:20:34 +11:00
2.19.1
2014-04-13 14:41:33 +10:00