mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-11-16 17:16:11 +00:00
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:
parent
6b368a38a2
commit
c6033a7e1c
@ -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());
|
||||
|
@ -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.
|
||||
*
|
||||
|
@ -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",
|
||||
|
Loading…
Reference in New Issue
Block a user