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

Dieser Commit ist enthalten in:
sk89q 2010-11-16 00:15:06 -08:00
Ursprung 6b368a38a2
Commit c6033a7e1c
3 geänderte Dateien mit 44 neuen und 0 gelöschten Zeilen

Datei anzeigen

@ -94,6 +94,11 @@ public class EditSession {
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());
if (block.getID() != 0) {
ServerInterface.setBlockData(pt, block.getData());

Datei anzeigen

@ -184,6 +184,32 @@ public class ServerInterface {
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.
*

Datei anzeigen

@ -79,6 +79,10 @@ public class WorldEditListener extends PluginListener {
*/
private GroupRestrictionsManager restrictions = new GroupRestrictionsManager();
/**
* True to time operations.
*/
private boolean profile;
/**
* List of allowed blocks.
*/
@ -1702,11 +1706,18 @@ public class WorldEditListener extends PluginListener {
new EditSession(session.getBlockChangeLimit());
editSession.enableQueue();
long start = System.currentTimeMillis();
try {
return performCommand(player, session, editSession, split);
} finally {
session.remember(editSession);
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();
}
profile = properties.getBoolean("debug-profile", false);
// Get allowed blocks
allowedBlocks = new HashSet<Integer>();
for (String b : properties.getString("allowed-blocks",