3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-12-26 02:50:06 +01:00

Flush clipboard rather than close on player disconnect

Addresses #1291
Dieser Commit ist enthalten in:
dordsor21 2021-09-13 15:08:03 +01:00
Ursprung 3088b1245c
Commit 06d716248e
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 1E53E88969FFCF0B
5 geänderte Dateien mit 39 neuen und 5 gelöschten Zeilen

Datei anzeigen

@ -61,4 +61,11 @@ public class LazyClipboardHolder extends URIClipboardHolder {
clipboard = null; clipboard = null;
} }
@Override
public synchronized void flush() {
if (clipboard instanceof BlockArrayClipboard) {
clipboard.flush();
}
}
} }

Datei anzeigen

@ -3,6 +3,7 @@ package com.fastasyncworldedit.core.extent.clipboard;
import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.session.ClipboardHolder; import com.sk89q.worldedit.session.ClipboardHolder;
import java.io.IOException;
import java.net.URI; import java.net.URI;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
@ -183,4 +184,15 @@ public class MultiClipboardHolder extends URIClipboardHolder {
} }
} }
@Override
public void flush() {
for (ClipboardHolder holder : holders) {
try {
holder.flush();
} catch (IOException e) {
e.printStackTrace();
}
}
}
} }

Datei anzeigen

@ -840,12 +840,16 @@ public class LocalSession implements TextureHolder {
} }
/** /**
* Ensure the player's clipboard is closed. (will only do something with clipboard-on-disk) * Ensure the player's clipboard is flushed. (will only do something with clipboard-on-disk)
*/ */
public void closeClipboard() { public void flushClipboard() {
synchronized (clipboardLock) { synchronized (clipboardLock) {
if (this.clipboard != null) { if (this.clipboard != null) {
this.clipboard.close(); try {
this.clipboard.flush();
} catch (IOException e) {
e.printStackTrace();
}
} }
} }
} }

Datei anzeigen

@ -391,7 +391,7 @@ public interface Player extends Entity, Actor {
*/ */
default void unregister() { default void unregister() {
cancel(true); cancel(true);
getSession().closeClipboard(); getSession().flushClipboard();
if (Settings.IMP.HISTORY.DELETE_ON_LOGOUT) { if (Settings.IMP.HISTORY.DELETE_ON_LOGOUT) {
getSession().clearHistory(); getSession().clearHistory();
} }

Datei anzeigen

@ -24,6 +24,9 @@ import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.math.transform.Identity; import com.sk89q.worldedit.math.transform.Identity;
import com.sk89q.worldedit.math.transform.Transform; import com.sk89q.worldedit.math.transform.Transform;
import java.io.Closeable;
import java.io.Flushable;
import java.io.IOException;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
@ -32,7 +35,8 @@ import static com.google.common.base.Preconditions.checkNotNull;
/** /**
* Holds the clipboard and the current transform on the clipboard. * Holds the clipboard and the current transform on the clipboard.
*/ */
public class ClipboardHolder { //FAWE start - closeable and flushable
public class ClipboardHolder implements Closeable, Flushable {
private Clipboard clipboard; private Clipboard clipboard;
private Transform transform = new Identity(); private Transform transform = new Identity();
@ -118,6 +122,7 @@ public class ClipboardHolder {
return new PasteBuilder(this, targetExtent); return new PasteBuilder(this, targetExtent);
} }
@Override
public void close() { public void close() {
if (clipboard != null) { if (clipboard != null) {
clipboard.close(); clipboard.close();
@ -125,5 +130,11 @@ public class ClipboardHolder {
clipboard = null; clipboard = null;
} }
@Override
public void flush() throws IOException {
if (clipboard != null) {
clipboard.flush();
}
}
} }