mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-06-11 20:13:55 +00:00
Added //fast mode, which allows the server to skip the dirtying of chunks. This means that you have to rejoin to see changes though, but most operations are doubled in speed.
This commit is contained in:
@ -87,15 +87,23 @@ public class EditSession {
|
||||
* indicates no limit.
|
||||
*/
|
||||
private int maxBlocks = -1;
|
||||
|
||||
/**
|
||||
* Indicates whether some types of blocks should be queued for best
|
||||
* reproduction.
|
||||
*/
|
||||
private boolean queued = false;
|
||||
|
||||
/**
|
||||
* Use the fast mode, which may leave chunks not flagged "dirty".
|
||||
*/
|
||||
private boolean fastMode = false;
|
||||
|
||||
/**
|
||||
* Block bag to use for getting blocks.
|
||||
*/
|
||||
private BlockBag blockBag;
|
||||
|
||||
/**
|
||||
* List of missing blocks;
|
||||
*/
|
||||
@ -185,11 +193,22 @@ public class EditSession {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
boolean result;
|
||||
|
||||
boolean result = world.setBlockType(pt, id);
|
||||
if (fastMode) {
|
||||
result = world.setBlockTypeFast(pt, id);
|
||||
} else {
|
||||
result = world.setBlockType(pt, id);
|
||||
}
|
||||
|
||||
if (id != 0) {
|
||||
if (BlockType.usesData(id)) {
|
||||
world.setBlockData(pt, block.getData());
|
||||
if (existing != type && block.getData() > 0 && BlockType.usesData(id)) {
|
||||
if (fastMode) {
|
||||
world.setBlockDataFast(pt, block.getData());
|
||||
} else {
|
||||
world.setBlockData(pt, block.getData());
|
||||
}
|
||||
}
|
||||
|
||||
// Signs
|
||||
@ -488,6 +507,24 @@ public class EditSession {
|
||||
}
|
||||
queued = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set fast mode.
|
||||
*
|
||||
* @param fastMode
|
||||
*/
|
||||
public void setFastMode(boolean fastMode) {
|
||||
this.fastMode = fastMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return fast mode status.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean hasFastMode() {
|
||||
return fastMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finish off the queue.
|
||||
|
@ -73,6 +73,7 @@ public class LocalSession {
|
||||
private String lastScript;
|
||||
private boolean beenToldVersion = false;
|
||||
private boolean hasCUISupport = false;
|
||||
private boolean fastMode = false;
|
||||
private TimeZone timezone = TimeZone.getDefault();
|
||||
|
||||
/**
|
||||
@ -144,6 +145,7 @@ public class LocalSession {
|
||||
EditSession newEditSession =
|
||||
new EditSession(editSession.getWorld(), -1, newBlockBag);
|
||||
newEditSession.enableQueue();
|
||||
newEditSession.setFastMode(fastMode);
|
||||
editSession.undo(newEditSession);
|
||||
return editSession;
|
||||
} else {
|
||||
@ -164,6 +166,7 @@ public class LocalSession {
|
||||
EditSession newEditSession =
|
||||
new EditSession(editSession.getWorld(), -1, newBlockBag);
|
||||
newEditSession.enableQueue();
|
||||
newEditSession.setFastMode(fastMode);
|
||||
editSession.redo(newEditSession);
|
||||
historyPointer++;
|
||||
return editSession;
|
||||
@ -642,4 +645,40 @@ public class LocalSession {
|
||||
public boolean hasExpired() {
|
||||
return System.currentTimeMillis() - expirationTime > EXPIRATION_GRACE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new edit session.
|
||||
*
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
public EditSession createEditSession(LocalPlayer player) {
|
||||
BlockBag blockBag = getBlockBag(player);
|
||||
|
||||
// Create an edit session
|
||||
EditSession editSession =
|
||||
new EditSession(player.getWorld(),
|
||||
getBlockChangeLimit(), blockBag);
|
||||
editSession.setFastMode(fastMode);
|
||||
|
||||
return editSession;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the session has fast mode enabled.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean hasFastMode() {
|
||||
return fastMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set fast mode.
|
||||
*
|
||||
* @param fastMode
|
||||
*/
|
||||
public void setFastMode(boolean fastMode) {
|
||||
this.fastMode = fastMode;
|
||||
}
|
||||
}
|
||||
|
@ -44,6 +44,17 @@ public abstract class LocalWorld {
|
||||
*/
|
||||
public abstract boolean setBlockType(Vector pt, int type);
|
||||
|
||||
/**
|
||||
* Set block type.
|
||||
*
|
||||
* @param pt
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
public boolean setBlockTypeFast(Vector pt, int type) {
|
||||
return setBlockType(pt, type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get block type.
|
||||
*
|
||||
@ -60,6 +71,16 @@ public abstract class LocalWorld {
|
||||
*/
|
||||
public abstract void setBlockData(Vector pt, int data);
|
||||
|
||||
/**
|
||||
* Set block data.
|
||||
*
|
||||
* @param pt
|
||||
* @param data
|
||||
*/
|
||||
public void setBlockDataFast(Vector pt, int data) {
|
||||
setBlockData(pt, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get block data.
|
||||
*
|
||||
|
@ -1010,16 +1010,11 @@ public class WorldEdit {
|
||||
}
|
||||
|
||||
LocalSession session = getSession(player);
|
||||
BlockBag blockBag = session.getBlockBag(player);
|
||||
|
||||
session.tellVersion(player);
|
||||
|
||||
// Create an edit session
|
||||
EditSession editSession =
|
||||
new EditSession(player.getWorld(),
|
||||
session.getBlockChangeLimit(), blockBag);
|
||||
EditSession editSession = session.createEditSession(player);
|
||||
editSession.enableQueue();
|
||||
|
||||
session.tellVersion(player);
|
||||
|
||||
long start = System.currentTimeMillis();
|
||||
|
||||
try {
|
||||
|
@ -81,6 +81,18 @@ public class BukkitWorld extends LocalWorld {
|
||||
return world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()).setTypeId(type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set block type.
|
||||
*
|
||||
* @param pt
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean setBlockTypeFast(Vector pt, int type) {
|
||||
return world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()).setTypeId(type, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get block type.
|
||||
*
|
||||
@ -101,7 +113,17 @@ public class BukkitWorld extends LocalWorld {
|
||||
@Override
|
||||
public void setBlockData(Vector pt, int data) {
|
||||
world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()).setData((byte)data);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Set block data.
|
||||
*
|
||||
* @param pt
|
||||
* @param data
|
||||
*/
|
||||
@Override
|
||||
public void setBlockDataFast(Vector pt, int data) {
|
||||
world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()).setData((byte)data, false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -60,6 +60,27 @@ public class GeneralCommands {
|
||||
player.print("Block change limit set to " + limit + ".");
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"/fast"},
|
||||
usage = "",
|
||||
desc = "Toggle fast mode",
|
||||
min = 0,
|
||||
max = 0
|
||||
)
|
||||
@CommandPermissions({"worldedit.fast"})
|
||||
public static void fast(CommandContext args, WorldEdit we,
|
||||
LocalSession session, LocalPlayer player, EditSession editSession)
|
||||
throws WorldEditException {
|
||||
|
||||
session.setFastMode(!session.hasFastMode());
|
||||
|
||||
if (session.hasFastMode()) {
|
||||
player.print("Fast mode enabled. You may need to rejoin to see changes.");
|
||||
} else {
|
||||
player.print("Fast mode disabled.");
|
||||
}
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"toggleplace"},
|
||||
usage = "",
|
||||
|
@ -56,8 +56,7 @@ public class AreaPickaxe implements BlockTool {
|
||||
return true;
|
||||
}
|
||||
|
||||
EditSession editSession =
|
||||
new EditSession(world, session.getBlockChangeLimit());
|
||||
EditSession editSession = session.createEditSession(player);
|
||||
|
||||
try {
|
||||
for (int x = ox - range; x <= ox + range; x++) {
|
||||
|
@ -50,9 +50,8 @@ public class FloatingTreeRemover implements BlockTool {
|
||||
|
||||
int initialType = world.getBlockType(clicked);
|
||||
int block;
|
||||
|
||||
EditSession editSession =
|
||||
new EditSession(world, session.getBlockChangeLimit());
|
||||
|
||||
EditSession editSession = session.createEditSession(player);
|
||||
|
||||
if (initialType != BlockID.LEAVES && initialType != BlockID.LOG) {
|
||||
player.printError("That's not a floating tree.");
|
||||
|
@ -56,9 +56,8 @@ public class RecursivePickaxe implements BlockTool {
|
||||
if (initialType == BlockID.BEDROCK && !player.canDestroyBedrock()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
EditSession editSession =
|
||||
new EditSession(world, session.getBlockChangeLimit());
|
||||
|
||||
EditSession editSession = session.createEditSession(player);
|
||||
|
||||
try {
|
||||
recurse(server, editSession, world, clicked.toBlockVector(),
|
||||
|
@ -41,9 +41,7 @@ public class TreePlanter implements BlockTool {
|
||||
public boolean actPrimary(ServerInterface server, LocalConfiguration config,
|
||||
LocalPlayer player, LocalSession session, WorldVector clicked) {
|
||||
|
||||
LocalWorld world = clicked.getWorld();
|
||||
EditSession editSession =
|
||||
new EditSession(world, session.getBlockChangeLimit());
|
||||
EditSession editSession = session.createEditSession(player);
|
||||
|
||||
try {
|
||||
if (!gen.generate(editSession, clicked.add(0, 1, 0))) {
|
||||
|
Reference in New Issue
Block a user