diff --git a/patches/server/0009-Fakeplayer-support.patch b/patches/server/0009-Fakeplayer-support.patch index 790c3933..5d1e3eb0 100644 --- a/patches/server/0009-Fakeplayer-support.patch +++ b/patches/server/0009-Fakeplayer-support.patch @@ -782,10 +782,10 @@ index 0000000000000000000000000000000000000000..07b688d376a4af88305e57519a5ae983 +} diff --git a/src/main/java/top/leavesmc/leaves/bot/BotUtil.java b/src/main/java/top/leavesmc/leaves/bot/BotUtil.java new file mode 100644 -index 0000000000000000000000000000000000000000..f3138e662d7cb58b083e202cd3c623d6ff3bc33d +index 0000000000000000000000000000000000000000..a609b0ff323ea4bc8a23a2b8be0d01c9e9d54d92 --- /dev/null +++ b/src/main/java/top/leavesmc/leaves/bot/BotUtil.java -@@ -0,0 +1,141 @@ +@@ -0,0 +1,147 @@ +package top.leavesmc.leaves.bot; + +import com.google.gson.JsonElement; @@ -885,10 +885,14 @@ index 0000000000000000000000000000000000000000..f3138e662d7cb58b083e202cd3c623d6 + invnbt.put("Inventory", bot.getInventory().save(new ListTag())); + + File file = MinecraftServer.getServer().getWorldPath(LevelResource.ROOT).resolve("fakeplayer/" + uuid + ".dat").toFile(); -+ if (file.isFile()) { -+ file.delete(); -+ } ++ File parent = file.getParentFile(); + try { ++ if (!parent.exists() || !parent.isDirectory()) { ++ parent.mkdirs(); ++ } ++ if (file.exists() && file.isFile()) { ++ file.delete(); ++ } + file.createNewFile(); + NbtIo.writeCompressed(invnbt, file); + } catch (IOException e) { @@ -914,13 +918,15 @@ index 0000000000000000000000000000000000000000..f3138e662d7cb58b083e202cd3c623d6 + if (fakePlayer.has("invuuid")) { + String uuid = fakePlayer.get("invuuid").getAsString(); + File file = MinecraftServer.getServer().getWorldPath(LevelResource.ROOT).resolve("fakeplayer/" + uuid + ".dat").toFile(); -+ try { -+ CompoundTag nbt = NbtIo.readCompressed(file); -+ inv = nbt.getList("Inventory", 10); -+ } catch (IOException e) { -+ e.printStackTrace(); ++ if (file.exists()) { ++ try { ++ CompoundTag nbt = NbtIo.readCompressed(file); ++ inv = nbt.getList("Inventory", 10); ++ } catch (IOException e) { ++ e.printStackTrace(); ++ } ++ file.delete(); + } -+ file.delete(); + } + + ServerBot.createBot(new Location(Bukkit.getWorld(dimension), pos_x, pos_y, pos_z, yaw, pitch),