mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-06 04:46:40 +00:00
Make EditSession closeable for easy flushing
This commit is contained in:
@ -172,29 +172,30 @@ public class BrushTool implements TraceTool {
|
||||
|
||||
BlockBag bag = session.getBlockBag(player);
|
||||
|
||||
EditSession editSession = session.createEditSession(player);
|
||||
Request.request().setEditSession(editSession);
|
||||
if (mask != null) {
|
||||
Mask existingMask = editSession.getMask();
|
||||
try (EditSession editSession = session.createEditSession(player)) {
|
||||
Request.request().setEditSession(editSession);
|
||||
if (mask != null) {
|
||||
Mask existingMask = editSession.getMask();
|
||||
|
||||
if (existingMask == null) {
|
||||
editSession.setMask(mask);
|
||||
} else if (existingMask instanceof MaskIntersection) {
|
||||
((MaskIntersection) existingMask).add(mask);
|
||||
} else {
|
||||
MaskIntersection newMask = new MaskIntersection(existingMask);
|
||||
newMask.add(mask);
|
||||
editSession.setMask(newMask);
|
||||
if (existingMask == null) {
|
||||
editSession.setMask(mask);
|
||||
} else if (existingMask instanceof MaskIntersection) {
|
||||
((MaskIntersection) existingMask).add(mask);
|
||||
} else {
|
||||
MaskIntersection newMask = new MaskIntersection(existingMask);
|
||||
newMask.add(mask);
|
||||
editSession.setMask(newMask);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
brush.build(editSession, target.toVector(), material, size);
|
||||
} catch (MaxChangedBlocksException e) {
|
||||
player.printError("Max blocks change limit reached.");
|
||||
try {
|
||||
brush.build(editSession, target.toVector(), material, size);
|
||||
} catch (MaxChangedBlocksException e) {
|
||||
player.printError("Max blocks change limit reached.");
|
||||
} finally {
|
||||
session.remember(editSession);
|
||||
}
|
||||
} finally {
|
||||
session.remember(editSession);
|
||||
editSession.flushSession();
|
||||
if (bag != null) {
|
||||
bag.flushChanges();
|
||||
}
|
||||
|
Reference in New Issue
Block a user