only close clipboard on error during copy

apply to //cut as well
This commit is contained in:
dordsor21 2021-09-11 00:27:26 +01:00
parent 470ba64fe4
commit db24b429c1
No known key found for this signature in database
GPG Key ID: 1E53E88969FFCF0B

View File

@ -139,8 +139,8 @@ public class ClipboardCommands {
}
session.setClipboard(null);
try (Clipboard clipboard = new BlockArrayClipboard(region, actor.getUniqueId())) {
Clipboard clipboard = new BlockArrayClipboard(region, actor.getUniqueId());
try {
clipboard.setOrigin(centerClipboard ? region.getCenter().toBlockPoint() : session.getPlacementPosition(actor));
ForwardExtentCopy copy = new ForwardExtentCopy(editSession, region, clipboard, region.getMinimumPoint());
copy.setCopyingEntities(copyEntities);
@ -170,6 +170,9 @@ public class ClipboardCommands {
session.setClipboard(new ClipboardHolder(clipboard));
copy.getStatusMessages().forEach(actor::print);
} catch (Throwable e) {
clipboard.close();
throw e;
}
//FAWE end
}
@ -274,6 +277,7 @@ public class ClipboardCommands {
session.setClipboard(null);
BlockArrayClipboard clipboard = new BlockArrayClipboard(region, actor.getUniqueId());
try {
clipboard.setOrigin(session.getPlacementPosition(actor));
ForwardExtentCopy copy = new ForwardExtentCopy(editSession, region, clipboard, region.getMinimumPoint());
copy.setSourceFunction(new BlockReplace(editSession, leavePattern));
@ -306,6 +310,10 @@ public class ClipboardCommands {
actor.print(Caption.of("fawe.tips.tip.lazycut"));
}
copy.getStatusMessages().forEach(actor::print);
} catch (Throwable e) {
clipboard.close();
throw e;
}
//FAWE end
}