From dd8ed8d5c68f0dcf5c8e0063821dc5190240ffa3 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Tue, 6 Sep 2022 21:34:07 +0200 Subject: [PATCH] Move clipboards to temp --- .../sk89q/worldedit/bukkit/BukkitPlayer.java | 2 +- .../clipboard/DiskOptimizedClipboard.java | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPlayer.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPlayer.java index acfd5cacd..f5ae8fbc2 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPlayer.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPlayer.java @@ -110,7 +110,7 @@ public class BukkitPlayer extends AbstractPlayerActor { if (player != null && Settings.settings().CLIPBOARD.USE_DISK) { BukkitPlayer cached = WorldEditPlugin.getInstance().getCachedPlayer(player); if (cached == null) { - loadClipboardFromDisk(); + //loadClipboardFromDisk(); } } //FAWE end diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/DiskOptimizedClipboard.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/DiskOptimizedClipboard.java index acdf9fad7..f87fd5afa 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/DiskOptimizedClipboard.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/DiskOptimizedClipboard.java @@ -71,16 +71,25 @@ public class DiskOptimizedClipboard extends LinearClipboard { private boolean canHaveBiomes = true; private int nbtBytesRemaining; + private static File createTmpFile() { + File temp; + try { + temp = File.createTempFile("fawe", ".bd"); + } catch (IOException e) { + throw new RuntimeException(e); + } + temp.deleteOnExit(); + + return temp; + } + /** * Creates a new DiskOptimizedClipboard for the given region. Creates or overwrites a file using the given UUID as a name. */ public DiskOptimizedClipboard(Region region, UUID uuid) { this( region.getDimensions(), - MainUtil.getFile( - Fawe.instance() != null ? Fawe.platform().getDirectory() : new File("."), - Settings.settings().PATHS.CLIPBOARD + File.separator + uuid + ".bd" - ) + createTmpFile() ); setOffset(region.getMinimumPoint()); setOrigin(region.getMinimumPoint());