Yatopia/patches/server/0041-Akarin-Avoid-double-I-O-operation-on-load-player-fil.patch
2020-06-23 16:39:42 +02:00

37 lines
1.9 KiB
Diff

From cc1010c26310272c4ba064408870bc5ca13c76f4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E3=84=97=E3=84=A0=CB=8B=20=E3=84=91=E3=84=A7=CB=8A?=
<tsao-chi@the-lingo.org>
Date: Thu, 2 Apr 2020 11:29:08 +0800
Subject: [PATCH] Akarin Avoid double I/O operation on load player file
---
src/main/java/net/minecraft/server/WorldNBTStorage.java | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/main/java/net/minecraft/server/WorldNBTStorage.java b/src/main/java/net/minecraft/server/WorldNBTStorage.java
index c80673770..65813c84e 100644
--- a/src/main/java/net/minecraft/server/WorldNBTStorage.java
+++ b/src/main/java/net/minecraft/server/WorldNBTStorage.java
@@ -178,7 +178,8 @@ public class WorldNBTStorage implements IPlayerFileData {
File file = new File(this.playerDir, entityhuman.getUniqueIDString() + ".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() )
@@ -189,7 +190,7 @@ public class WorldNBTStorage implements 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
--
2.25.1.windows.1