Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-12-25 02:20:07 +01:00
Flush clipboard rather than close on player disconnect
Addresses #1291
Dieser Commit ist enthalten in:
Ursprung
3088b1245c
Commit
06d716248e
@ -61,4 +61,11 @@ public class LazyClipboardHolder extends URIClipboardHolder {
|
||||
clipboard = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void flush() {
|
||||
if (clipboard instanceof BlockArrayClipboard) {
|
||||
clipboard.flush();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package com.fastasyncworldedit.core.extent.clipboard;
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import com.sk89q.worldedit.session.ClipboardHolder;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.util.ArrayList;
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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) {
|
||||
if (this.clipboard != null) {
|
||||
this.clipboard.close();
|
||||
try {
|
||||
this.clipboard.flush();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -391,7 +391,7 @@ public interface Player extends Entity, Actor {
|
||||
*/
|
||||
default void unregister() {
|
||||
cancel(true);
|
||||
getSession().closeClipboard();
|
||||
getSession().flushClipboard();
|
||||
if (Settings.IMP.HISTORY.DELETE_ON_LOGOUT) {
|
||||
getSession().clearHistory();
|
||||
}
|
||||
|
@ -24,6 +24,9 @@ import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import com.sk89q.worldedit.math.transform.Identity;
|
||||
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.List;
|
||||
|
||||
@ -32,7 +35,8 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
/**
|
||||
* 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 Transform transform = new Identity();
|
||||
@ -118,6 +122,7 @@ public class ClipboardHolder {
|
||||
return new PasteBuilder(this, targetExtent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
if (clipboard != null) {
|
||||
clipboard.close();
|
||||
@ -125,5 +130,11 @@ public class ClipboardHolder {
|
||||
clipboard = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flush() throws IOException {
|
||||
if (clipboard != null) {
|
||||
clipboard.flush();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren