parent
9a6d57f2e2
commit
2bb077f94f
2 changed files with 19 additions and 2 deletions
|
@ -124,7 +124,7 @@ public class BlockListener implements Listener {
|
||||||
if (mod.isDebug())
|
if (mod.isDebug())
|
||||||
mod.getLog().debug("PistionExtend moves "+sblock.getType()+"-Block from "+sblock.getLocation()+" to "+dest.getLocation());
|
mod.getLog().debug("PistionExtend moves "+sblock.getType()+"-Block from "+sblock.getLocation()+" to "+dest.getLocation());
|
||||||
|
|
||||||
mod.getQueries().move(sblock.getLocation(), dest.getLocation());
|
mod.getModel().moveState(sblock, dest);
|
||||||
}
|
}
|
||||||
mod.getQueries().getDB().endTransaction();
|
mod.getQueries().getDB().endTransaction();
|
||||||
}
|
}
|
||||||
|
@ -148,8 +148,12 @@ public class BlockListener implements Listener {
|
||||||
try {
|
try {
|
||||||
if (mod.isDebug())
|
if (mod.isDebug())
|
||||||
mod.getLog().debug("PistionRetract moves "+source.getType()+"-Block from "+source.getLocation()+" to "+dest.getLocation());
|
mod.getLog().debug("PistionRetract moves "+source.getType()+"-Block from "+source.getLocation()+" to "+dest.getLocation());
|
||||||
mod.getQueries().move(source.getLocation(), source.getRelative(event.getDirection().getOppositeFace()).getLocation());
|
mod.getModel().moveState(source, source.getRelative(event.getDirection().getOppositeFace()));
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
|
try {
|
||||||
|
mod.getQueries().getDB().revertTransaction();
|
||||||
|
} catch (SQLException e1) {
|
||||||
|
}
|
||||||
mod.getLog().warn("DB-Error while onBlockMove (retract): "+e.getMessage());
|
mod.getLog().warn("DB-Error while onBlockMove (retract): "+e.getMessage());
|
||||||
//event.setCancelled(true);
|
//event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,19 @@ public class DBModel {
|
||||||
this.q = mod.getQueries();
|
this.q = mod.getQueries();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void moveState(Block from, Block to) throws SQLException {
|
||||||
|
q.delete(to.getLocation());
|
||||||
|
q.move(from.getLocation(), to.getLocation());
|
||||||
|
HasBlockState metaBlock = getMetaBlock(from);
|
||||||
|
if (metaBlock.set) {
|
||||||
|
BlockState state = metaBlock.state;
|
||||||
|
state.setLocation(to.getLocation());
|
||||||
|
setMetaBlock(to, getMetaBlock(from).state);
|
||||||
|
} else {
|
||||||
|
removeMetaBlock(to);
|
||||||
|
}
|
||||||
|
setMetaBlock(from, null);
|
||||||
|
}
|
||||||
public void removeState(BlockState state) throws SQLException {
|
public void removeState(BlockState state) throws SQLException {
|
||||||
//removeMetaBlock(state.getLocation().getBlock());
|
//removeMetaBlock(state.getLocation().getBlock());
|
||||||
setMetaBlock(state.getLocation().getBlock(), null);
|
setMetaBlock(state.getLocation().getBlock(), null);
|
||||||
|
|
Loading…
Reference in a new issue