Avoid double I/O operation on load player file

This commit is contained in:
Sotr
2019-03-28 14:22:49 +08:00
parent 69b28780a5
commit 5a4bc4b4ba

View File

@@ -219,7 +219,8 @@ public class WorldNBTStorage implements IDataManager, IPlayerFileData {
File file = new File(this.playerDir, entityhuman.bu() + ".dat");
// Spigot Start
boolean usingWrongFile = false;
if ( org.bukkit.Bukkit.getOnlineMode() && !file.exists() ) // Paper - Check online mode first
boolean normalFile = file.exists() && file.isFile(); // Akarin - ensures normal file
if ( org.bukkit.Bukkit.getOnlineMode() && !normalFile ) // Paper - Check online mode first // Akarin - ensures normal file
{
file = new File( this.playerDir, UUID.nameUUIDFromBytes( ( "OfflinePlayer:" + entityhuman.getName() ).getBytes( "UTF-8" ) ).toString() + ".dat");
if ( file.exists() )
@@ -230,7 +231,7 @@ public class WorldNBTStorage implements IDataManager, IPlayerFileData {
}
// Spigot End
if (file.exists() && file.isFile()) {
if (normalFile) { // Akarin - avoid double I/O operation
nbttagcompound = NBTCompressedStreamTools.a((InputStream) (new FileInputStream(file)));
}
// Spigot Start