Paper/CraftBukkit-Patches/0120-Use-Offline-Player-Data-Once-if-Required.patch
Zach Brown cab333b217 Rebase (Update) from upstream SpigotMC
Don't send requests of every player was found in the global api cache SpigotMC/Spigot@841270ff1e
Correctly set the response code for the cached lookups and return the ... SpigotMC/Spigot@f170b7899c
Don't try and re-set the global api cache on reload SpigotMC/Spigot@b410a00a66
Use a compile time sneaky throw hack. SpigotMC/Spigot@508462b96b
Fix a missed rename in WorldGenGroundBush SpigotMC/Spigot@0614d8fae9
2014-11-28 14:19:07 -06:00

44 lines
2.0 KiB
Diff

From 793e8163060e5f9319d7b1126159c739d59dd54c 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 93ff8d3..efdcad7 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() + ".dat");
+ 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.9.1