mirror of
https://hub.spigotmc.org/stash/scm/spigot/spigot.git
synced 2024-11-24 14:06:31 +00:00
46 lines
2.3 KiB
Diff
46 lines
2.3 KiB
Diff
From 00541cc6e5f3c3d9d35406a7c23ac968be80d5fd 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/world/level/storage/WorldNBTStorage.java b/src/main/java/net/minecraft/world/level/storage/WorldNBTStorage.java
|
|
index 935acab0e9..c79f0fbd91 100644
|
|
--- a/src/main/java/net/minecraft/world/level/storage/WorldNBTStorage.java
|
|
+++ b/src/main/java/net/minecraft/world/level/storage/WorldNBTStorage.java
|
|
@@ -75,10 +75,29 @@ public class WorldNBTStorage {
|
|
File file = this.playerDir;
|
|
// String s1 = entityhuman.getStringUUID(); // CraftBukkit - used above
|
|
File file1 = new File(file, s1 + s);
|
|
+ // Spigot Start
|
|
+ boolean usingWrongFile = false;
|
|
+ if ( !file1.exists() )
|
|
+ {
|
|
+ file1 = new File( file, java.util.UUID.nameUUIDFromBytes( ( "OfflinePlayer:" + name ).getBytes( java.nio.charset.StandardCharsets.UTF_8 ) ).toString() + s );
|
|
+ if ( file1.exists() )
|
|
+ {
|
|
+ usingWrongFile = true;
|
|
+ org.bukkit.Bukkit.getServer().getLogger().warning( "Using offline mode UUID file for player " + name + " as it is the only copy we can find." );
|
|
+ }
|
|
+ }
|
|
+ // Spigot End
|
|
|
|
if (file1.exists() && file1.isFile()) {
|
|
try {
|
|
- return Optional.of(NBTCompressedStreamTools.readCompressed(file1.toPath(), NBTReadLimiter.unlimitedHeap()));
|
|
+ // Spigot Start
|
|
+ Optional<NBTTagCompound> optional = Optional.of(NBTCompressedStreamTools.readCompressed(file1.toPath(), NBTReadLimiter.unlimitedHeap()));
|
|
+ if ( usingWrongFile )
|
|
+ {
|
|
+ file1.renameTo( new File( file1.getPath() + ".offline-read" ) );
|
|
+ }
|
|
+ return optional;
|
|
+ // Spigot End
|
|
} catch (Exception exception) {
|
|
WorldNBTStorage.LOGGER.warn("Failed to load player data for {}", name); // CraftBukkit
|
|
}
|
|
--
|
|
2.47.0
|
|
|