3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-12-25 18:40:05 +01:00

Allow deletion of DOC

Fixes #1325
Dieser Commit ist enthalten in:
dordsor21 2021-09-27 14:39:21 +01:00
Ursprung b73db47e01
Commit 1cf5899586
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 1E53E88969FFCF0B
3 geänderte Dateien mit 42 neuen und 6 gelöschten Zeilen

Datei anzeigen

@ -511,8 +511,7 @@ public class Settings extends Config {
@Comment("Number of days to keep history on disk before deleting it")
public int DELETE_AFTER_DAYS = 1;
@Comment({
"If a players clipboard should be removed from memory upon player logout,",
" - Will not delete clipboards on disk"
"If a player's clipboard should be deleted upon logout"
})
public boolean DELETE_ON_LOGOUT = false;

Datei anzeigen

@ -24,6 +24,7 @@ import com.fastasyncworldedit.core.FaweCache;
import com.fastasyncworldedit.core.configuration.Caption;
import com.fastasyncworldedit.core.configuration.Settings;
import com.fastasyncworldedit.core.event.extent.PasteEvent;
import com.fastasyncworldedit.core.extent.clipboard.DiskOptimizedClipboard;
import com.fastasyncworldedit.core.extent.clipboard.MultiClipboardHolder;
import com.fastasyncworldedit.core.extent.clipboard.ReadOnlyClipboard;
import com.fastasyncworldedit.core.extent.clipboard.URIClipboardHolder;
@ -609,6 +610,24 @@ public class ClipboardCommands {
)
@CommandPermissions("worldedit.clipboard.clear")
public void clearClipboard(Actor actor, LocalSession session) throws WorldEditException {
//FAWE start - delete DOC
ClipboardHolder holder = session.getExistingClipboard();
if (holder == null) {
return;
}
for (Clipboard clipboard : holder.getClipboards()) {
DiskOptimizedClipboard doc;
if (clipboard instanceof DiskOptimizedClipboard) {
doc = (DiskOptimizedClipboard) clipboard;
} else if (clipboard instanceof BlockArrayClipboard && ((BlockArrayClipboard) clipboard).getParent() instanceof DiskOptimizedClipboard) {
doc = (DiskOptimizedClipboard) ((BlockArrayClipboard) clipboard).getParent();
} else {
continue;
}
doc.close(); // Ensure closed before deletion
doc.getFile().delete();
}
//FAWE end
session.setClipboard(null);
actor.print(Caption.of("worldedit.clearclipboard.cleared"));
}

Datei anzeigen

@ -33,6 +33,7 @@ import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.blocks.BaseItemStack;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.extent.inventory.BlockBag;
import com.sk89q.worldedit.function.mask.Mask;
@ -387,15 +388,32 @@ public interface Player extends Entity, Actor {
}
/**
* Unregister this player, deleting all data stored during the logon session.
* Unregister this player, deleting all data stored during the login session.
*/
default void unregister() {
cancel(true);
if (Settings.IMP.CLIPBOARD.DELETE_ON_LOGOUT || Settings.IMP.CLIPBOARD.USE_DISK) {
getSession().setClipboard(null);
LocalSession session = getSession();
if (Settings.IMP.CLIPBOARD.USE_DISK && Settings.IMP.CLIPBOARD.DELETE_ON_LOGOUT) {
ClipboardHolder holder = session.getExistingClipboard();
if (holder != null) {
for (Clipboard clipboard : holder.getClipboards()) {
DiskOptimizedClipboard doc;
if (clipboard instanceof DiskOptimizedClipboard) {
doc = (DiskOptimizedClipboard) clipboard;
} else if (clipboard instanceof BlockArrayClipboard && ((BlockArrayClipboard) clipboard).getParent() instanceof DiskOptimizedClipboard) {
doc = (DiskOptimizedClipboard) ((BlockArrayClipboard) clipboard).getParent();
} else {
continue;
}
doc.close(); // Ensure closed before deletion
doc.getFile().delete();
}
}
} else if (Settings.IMP.CLIPBOARD.DELETE_ON_LOGOUT || Settings.IMP.CLIPBOARD.USE_DISK) {
session.setClipboard(null);
}
if (Settings.IMP.HISTORY.DELETE_ON_LOGOUT) {
getSession().clearHistory();
session.clearHistory();
}
}