PaperSpigot-Parent/CraftBukkit-Patches/0104-Use-Offline-Player-Data-Once-if-Required.patch
Zach Brown 1c49ff69f4 Update Spigot's Patches round 2?
The hell happened here.
:
Fix Build 2339ac14a8e
Regen the patches 89d3fcbdfaf

This new system breaks a lot :(
2014-11-28 18:06:26 -06:00

44 lines
2.0 KiB
Diff

From e98d6b717bef858004359c11e2229d0566989723 Mon Sep 17 00:00:00 2001
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
index 6fa10cc..ee79cbd 100644
--- a/src/main/java/net/minecraft/server/WorldNBTStorage.java
+++ b/src/main/java/net/minecraft/server/WorldNBTStorage.java
@@ -200,10 +200,28 @@ public class WorldNBTStorage implements IDataManager, IPlayerFileData {
try {
File file = new File(this.playerDir, entityhuman.getUniqueID().toString() + ".dat");
+ // Spigot Start
+ boolean usingWrongFile = false;
+ if ( !file.exists() )
+ {
+ file = new File( this.playerDir, UUID.nameUUIDFromBytes( ( "OfflinePlayer:" + entityhuman.getName() ).getBytes( "UTF-8" ) ).toString() + ".dat");
+ if ( file.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 (file.exists() && file.isFile()) {
nbttagcompound = NBTCompressedStreamTools.a((InputStream) (new FileInputStream(file)));
}
+ // Spigot Start
+ if ( usingWrongFile )
+ {
+ file.renameTo( new File( file.getPath() + ".offline-read" ) );
+ }
+ // Spigot End
} catch (Exception exception) {
WorldNBTStorage.a.warn("Failed to load player data for " + entityhuman.getName());
}
--
2.1.0