From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: AlphaKR93 Date: Wed, 27 Sep 2023 22:13:07 +0900 Subject: [PATCH] Avoid double I/O operation on load player file diff --git a/src/main/java/net/minecraft/world/level/storage/PlayerDataStorage.java b/src/main/java/net/minecraft/world/level/storage/PlayerDataStorage.java index b3a90d6ef0e17c236e0b3c46e2d0012671afdaa7..eb1c8bb352bfcc81f61174fd65867390aa2cc2d2 100644 --- a/src/main/java/net/minecraft/world/level/storage/PlayerDataStorage.java +++ b/src/main/java/net/minecraft/world/level/storage/PlayerDataStorage.java @@ -60,7 +60,8 @@ public class PlayerDataStorage { File file = new File(this.playerDir, player.getStringUUID() + ".dat"); // Spigot Start boolean usingWrongFile = false; - if ( org.bukkit.Bukkit.getOnlineMode() && !file.exists() ) // Paper - Check online mode first + boolean isNormalFile = file.exists() && file.isFile(); // Plazma - Avoid double I/O operation + if ( org.bukkit.Bukkit.getOnlineMode() && !isNormalFile ) // Paper - Check online mode first // Plazma - Avoid double I/O operation { file = new File( this.playerDir, java.util.UUID.nameUUIDFromBytes( ( "OfflinePlayer:" + player.getScoreboardName() ).getBytes( "UTF-8" ) ).toString() + ".dat"); if ( file.exists() ) @@ -71,7 +72,7 @@ public class PlayerDataStorage { } // Spigot End - if (file.exists() && file.isFile()) { + if (isNormalFile) { // Plazma - Avoid double I/O operation nbttagcompound = NbtIo.readCompressed(file.toPath(), NbtAccounter.unlimitedHeap()); } // Spigot Start