Allow other edits than block edits

This commit is contained in:
Brokkonaut
2018-11-08 15:54:59 +01:00
parent f9d246dd63
commit 868c56ef6a
2 changed files with 11 additions and 7 deletions

View File

@@ -697,7 +697,7 @@ public class CommandsHandler implements CommandExecutor {
if (stack != null) {
chestaccess = new ChestAccess(stack, rs.getBoolean("itemremove"), rs.getInt("itemtype"));
}
editor.queueEdit(rs.getInt("x"), rs.getInt("y"), rs.getInt("z"), rs.getInt("replaced"), rs.getInt("replacedData"), rs.getBytes("replacedState"), rs.getInt("type"), rs.getInt("typeData"), rs.getBytes("typeState"), chestaccess);
editor.queueBlockEdit(rs.getInt("x"), rs.getInt("y"), rs.getInt("z"), rs.getInt("replaced"), rs.getInt("replacedData"), rs.getBytes("replacedState"), rs.getInt("type"), rs.getInt("typeData"), rs.getBytes("typeState"), chestaccess);
}
final int changes = editor.getSize();
if (changes > 10000) {
@@ -787,7 +787,7 @@ public class CommandsHandler implements CommandExecutor {
if (stack != null) {
chestaccess = new ChestAccess(stack, !rs.getBoolean("itemremove"), rs.getInt("itemtype"));
}
editor.queueEdit(rs.getInt("x"), rs.getInt("y"), rs.getInt("z"), rs.getInt("type"), rs.getInt("typeData"), rs.getBytes("typeState"), rs.getInt("replaced"), rs.getInt("replacedData"), rs.getBytes("replacedState"), chestaccess);
editor.queueBlockEdit(rs.getInt("x"), rs.getInt("y"), rs.getInt("z"), rs.getInt("type"), rs.getInt("typeData"), rs.getBytes("typeState"), rs.getInt("replaced"), rs.getInt("replacedData"), rs.getBytes("replacedState"), chestaccess);
}
final int changes = editor.getSize();
if (!params.silent) {

View File

@@ -83,8 +83,8 @@ public class WorldEditor implements Runnable {
this.sender = sender;
}
public void queueEdit(int x, int y, int z, int replaced, int replaceData, byte[] replacedState, int type, int typeData, byte[] typeState, ChestAccess item) {
edits.add(new Edit(0, new Location(world, x, y, z), null, replaced, replaceData, replacedState, type, typeData, typeState, item));
public void queueBlockEdit(int x, int y, int z, int replaced, int replaceData, byte[] replacedState, int type, int typeData, byte[] typeState, ChestAccess item) {
edits.add(new BlockEdit(0, new Location(world, x, y, z), null, replaced, replaceData, replacedState, type, typeData, typeState, item));
}
public long getElapsedTime() {
@@ -159,12 +159,16 @@ public class WorldEditor implements Runnable {
SUCCESS, BLACKLISTED, NO_ACTION
}
private class Edit extends BlockChange {
public Edit(long time, Location loc, Actor actor, int replaced, int replaceData, byte[] replacedState, int type, int typeData, byte[] typeState, ChestAccess ca) {
private interface Edit {
PerformResult perform() throws WorldEditorException;
}
private class BlockEdit extends BlockChange implements Edit {
public BlockEdit(long time, Location loc, Actor actor, int replaced, int replaceData, byte[] replacedState, int type, int typeData, byte[] typeState, ChestAccess ca) {
super(time, loc, actor, replaced, replaceData,replacedState , type, typeData, typeState, ca);
}
PerformResult perform() throws WorldEditorException {
public PerformResult perform() throws WorldEditorException {
BlockData replacedBlock = getBlockReplaced();
BlockData setBlock = getBlockSet();
if (replacedBlock == null || setBlock == null) {