From 67d52b3915e10b845965b51fcf274a7420315f7d Mon Sep 17 00:00:00 2001 From: Spigot Date: Sun, 13 Apr 2014 14:41:33 +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. By: md_5 --- ...Offline-Player-Data-Once-if-Required.patch | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 CraftBukkit-Patches/0131-Use-Offline-Player-Data-Once-if-Required.patch diff --git a/CraftBukkit-Patches/0131-Use-Offline-Player-Data-Once-if-Required.patch b/CraftBukkit-Patches/0131-Use-Offline-Player-Data-Once-if-Required.patch new file mode 100644 index 0000000000..387142629e --- /dev/null +++ b/CraftBukkit-Patches/0131-Use-Offline-Player-Data-Once-if-Required.patch @@ -0,0 +1,43 @@ +From a5991905982ab3d4eee97b4b7e59771d5c17ddbf Mon Sep 17 00:00:00 2001 +From: md_5 +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 +index fabc72b..89ba461 100644 +--- a/src/main/java/net/minecraft/server/WorldNBTStorage.java ++++ b/src/main/java/net/minecraft/server/WorldNBTStorage.java +@@ -196,10 +196,28 @@ public class WorldNBTStorage implements IDataManager, IPlayerFileData { + + try { + File file1 = new File(this.playerDir, entityhuman.getUniqueID().toString() + ".dat"); ++ // Spigot Start ++ boolean usingWrongFile = false; ++ if ( !file1.exists() ) ++ { ++ file1 = new File( this.playerDir, UUID.nameUUIDFromBytes( ( "OfflinePlayer:" + entityhuman.getName() ).getBytes( "UTF-8" ) ).toString() ); ++ if ( file1.exists() ) ++ { ++ 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 + + if (file1.exists() && file1.isFile()) { + nbttagcompound = NBTCompressedStreamTools.a((InputStream) (new FileInputStream(file1))); + } ++ // Spigot Start ++ if ( usingWrongFile ) ++ { ++ file1.renameTo( new File( file1.getPath() + ".offline-read" ) ); ++ } ++ // Spigot End + } catch (Exception exception) { + a.warn("Failed to load player data for " + entityhuman.getName()); + } +-- +1.8.3.2 +