Chests are now empty when removed (so they longer drop their items). Profile debugging mode added that prints how long an operation took.

This commit is contained in:
sk89q 2010-11-16 00:15:06 -08:00
parent 6b368a38a2
commit c6033a7e1c
3 changed files with 44 additions and 0 deletions

View File

@ -94,6 +94,11 @@ public class EditSession {
return false; return false;
} }
// Clear the chest so that it doesn't drop items
if (ServerInterface.getBlockType(pt) == 54) {
ServerInterface.clearChest(pt);
}
boolean result = ServerInterface.setBlockType(pt, block.getID()); boolean result = ServerInterface.setBlockType(pt, block.getID());
if (block.getID() != 0) { if (block.getID() != 0) {
ServerInterface.setBlockData(pt, block.getData()); ServerInterface.setBlockData(pt, block.getData());

View File

@ -184,6 +184,32 @@ public class ServerInterface {
return true; return true;
} }
/**
* Clear a chest's contents.
*
* @param pt
*/
public static boolean clearChest(Vector pt) {
ComplexBlock cblock = etc.getServer().getComplexBlock(
pt.getBlockX(), pt.getBlockY(), pt.getBlockZ());
if (!(cblock instanceof Chest)) {
return false;
}
Chest chest = (Chest)cblock;
hj[] itemArray = chest.getArray();
// Find an existing slot to put it into
for (int i = 0; itemArray.length > i; i++) {
itemArray[i] = null;
}
chest.update();
return true;
}
/** /**
* Generate a tree at a location. * Generate a tree at a location.
* *

View File

@ -79,6 +79,10 @@ public class WorldEditListener extends PluginListener {
*/ */
private GroupRestrictionsManager restrictions = new GroupRestrictionsManager(); private GroupRestrictionsManager restrictions = new GroupRestrictionsManager();
/**
* True to time operations.
*/
private boolean profile;
/** /**
* List of allowed blocks. * List of allowed blocks.
*/ */
@ -1702,11 +1706,18 @@ public class WorldEditListener extends PluginListener {
new EditSession(session.getBlockChangeLimit()); new EditSession(session.getBlockChangeLimit());
editSession.enableQueue(); editSession.enableQueue();
long start = System.currentTimeMillis();
try { try {
return performCommand(player, session, editSession, split); return performCommand(player, session, editSession, split);
} finally { } finally {
session.remember(editSession); session.remember(editSession);
editSession.flushQueue(); editSession.flushQueue();
if (profile) {
long time = System.currentTimeMillis() - start;
ply.sendMessage(Colors.Yellow + (time / 1000.0) + "s elapsed");
}
} }
} }
} }
@ -1774,6 +1785,8 @@ public class WorldEditListener extends PluginListener {
properties.load(); properties.load();
} }
profile = properties.getBoolean("debug-profile", false);
// Get allowed blocks // Get allowed blocks
allowedBlocks = new HashSet<Integer>(); allowedBlocks = new HashSet<Integer>();
for (String b : properties.getString("allowed-blocks", for (String b : properties.getString("allowed-blocks",