mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-23 01:37:37 +00:00
Make lrbuild tool use history.
This commit is contained in:
parent
e5fe051340
commit
2b1a7ed943
@ -26,6 +26,7 @@ import com.sk89q.worldedit.MaxChangedBlocksException;
|
|||||||
import com.sk89q.worldedit.entity.Player;
|
import com.sk89q.worldedit.entity.Player;
|
||||||
import com.sk89q.worldedit.extension.platform.Actor;
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
import com.sk89q.worldedit.extension.platform.Platform;
|
import com.sk89q.worldedit.extension.platform.Platform;
|
||||||
|
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
||||||
import com.sk89q.worldedit.function.mask.Mask;
|
import com.sk89q.worldedit.function.mask.Mask;
|
||||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
@ -55,41 +56,56 @@ public class LongRangeBuildTool extends BrushTool implements DoubleActionTraceTo
|
|||||||
public boolean actSecondary(Platform server, LocalConfiguration config, Player player, LocalSession session) {
|
public boolean actSecondary(Platform server, LocalConfiguration config, Player player, LocalSession session) {
|
||||||
Location pos = getTargetFace(player);
|
Location pos = getTargetFace(player);
|
||||||
if (pos == null) return false;
|
if (pos == null) return false;
|
||||||
try (EditSession eS = session.createEditSession(player)) {
|
BlockBag bag = session.getBlockBag(player);
|
||||||
eS.disableBuffering();
|
|
||||||
BlockVector3 blockPoint = pos.toVector().toBlockPoint();
|
|
||||||
BaseBlock applied = secondary.apply(blockPoint);
|
|
||||||
if (applied.getBlockType().getMaterial().isAir()) {
|
|
||||||
eS.setBlock(blockPoint, secondary);
|
|
||||||
} else {
|
|
||||||
eS.setBlock(pos.toVector().subtract(pos.getDirection()).toBlockPoint(), secondary);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
} catch (MaxChangedBlocksException ignored) {
|
|
||||||
// one block? eat it
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
|
|
||||||
|
try (EditSession editSession = session.createEditSession(player)) {
|
||||||
|
try {
|
||||||
|
editSession.disableBuffering();
|
||||||
|
BlockVector3 blockPoint = pos.toVector().toBlockPoint();
|
||||||
|
BaseBlock applied = secondary.apply(blockPoint);
|
||||||
|
if (applied.getBlockType().getMaterial().isAir()) {
|
||||||
|
editSession.setBlock(blockPoint, secondary);
|
||||||
|
} else {
|
||||||
|
editSession.setBlock(pos.toVector().subtract(pos.getDirection()).toBlockPoint(), secondary);
|
||||||
|
}
|
||||||
|
} catch (MaxChangedBlocksException ignored) {
|
||||||
|
} finally {
|
||||||
|
session.remember(editSession);
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
if (bag != null) {
|
||||||
|
bag.flushChanges();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session) {
|
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session) {
|
||||||
Location pos = getTargetFace(player);
|
Location pos = getTargetFace(player);
|
||||||
if (pos == null) return false;
|
if (pos == null) return false;
|
||||||
try (EditSession eS = session.createEditSession(player)) {
|
BlockBag bag = session.getBlockBag(player);
|
||||||
eS.disableBuffering();
|
|
||||||
BlockVector3 blockPoint = pos.toVector().toBlockPoint();
|
try (EditSession editSession = session.createEditSession(player)) {
|
||||||
BaseBlock applied = primary.apply(blockPoint);
|
try {
|
||||||
if (applied.getBlockType().getMaterial().isAir()) {
|
editSession.disableBuffering();
|
||||||
eS.setBlock(blockPoint, primary);
|
BlockVector3 blockPoint = pos.toVector().toBlockPoint();
|
||||||
} else {
|
BaseBlock applied = primary.apply(blockPoint);
|
||||||
eS.setBlock(pos.toVector().subtract(pos.getDirection()).toBlockPoint(), primary);
|
if (applied.getBlockType().getMaterial().isAir()) {
|
||||||
|
editSession.setBlock(blockPoint, primary);
|
||||||
|
} else {
|
||||||
|
editSession.setBlock(pos.toVector().subtract(pos.getDirection()).toBlockPoint(), primary);
|
||||||
|
}
|
||||||
|
} catch (MaxChangedBlocksException ignored) {
|
||||||
|
} finally {
|
||||||
|
session.remember(editSession);
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
if (bag != null) {
|
||||||
|
bag.flushChanges();
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
} catch (MaxChangedBlocksException ignored) {
|
|
||||||
// one block? eat it
|
|
||||||
}
|
}
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Location getTargetFace(Player player) {
|
private Location getTargetFace(Player player) {
|
||||||
|
Loading…
Reference in New Issue
Block a user