3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-16 03:20:07 +01:00
Paper/CraftBukkit-Patches/0100-Use-Offline-Player-Data-Once-if-Required.patch

44 Zeilen
2.0 KiB
Diff

2015-06-01 11:22:52 +02:00
From 9f634b85d230ef4a9d556742500fcfaffe39e07c 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
2015-05-09 22:23:26 +02:00
index 616b049..e4b3dd5 100644
--- a/src/main/java/net/minecraft/server/WorldNBTStorage.java
+++ b/src/main/java/net/minecraft/server/WorldNBTStorage.java
2014-11-28 02:17:45 +01:00
@@ -200,10 +200,28 @@ public class WorldNBTStorage implements IDataManager, IPlayerFileData {
try {
2014-11-28 02:17:45 +01:00
File file = new File(this.playerDir, entityhuman.getUniqueID().toString() + ".dat");
+ // Spigot Start
+ boolean usingWrongFile = false;
2014-11-28 02:17:45 +01:00
+ if ( !file.exists() )
+ {
2014-11-28 02:17:45 +01:00
+ 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
2014-11-28 02:17:45 +01:00
if (file.exists() && file.isFile()) {
nbttagcompound = NBTCompressedStreamTools.a((InputStream) (new FileInputStream(file)));
}
+ // Spigot Start
+ if ( usingWrongFile )
+ {
2014-11-28 02:17:45 +01:00
+ file.renameTo( new File( file.getPath() + ".offline-read" ) );
+ }
+ // Spigot End
} catch (Exception exception) {
2014-11-28 02:17:45 +01:00
WorldNBTStorage.a.warn("Failed to load player data for " + entityhuman.getName());
}
--
2015-05-09 22:23:26 +02:00
2.1.4