示例#1
0
 @Override
 public void setBlock(String playerName, Block block, Location loc1, Location loc2) {
   Area area = new Area(loc1, loc2);
   List<Block> blocks = new LinkedList<Block>();
   int chX1 = area.getX1() >> 4;
   int chZ1 = area.getZ1() >> 4;
   int chX2 = area.getX2() >> 4;
   int chZ2 = area.getZ2() >> 4;
   Clipboard undo = Clipboard.createUndoClipBoard(playerName);
   for (int chX = chX1; chX <= chX2; chX++)
     for (int chZ = chZ1; chZ <= chZ2; chZ++) {
       for (int x = 0; x < 16; x++)
         for (int z = 0; z < 16; z++) {
           int blockX = x + (chX << 4);
           int blockZ = z + (chZ << 4);
           if (blockX < area.getX1() || blockX > area.getX2()) continue;
           if (blockZ < area.getZ1() || blockZ > area.getZ2()) continue;
           for (int y = area.getY1(); y <= area.getY2(); y++) {
             Position position = new Position(blockX, y, blockZ, area.getLevel());
             if (undo != null) undo.add(position.getLevel().getBlock(position));
             blocks.add(Block.get(block.getId(), block.getDamage(), position));
           }
         }
     }
   if (undo != null) getUndoManager().add(undo);
   Message.debugMessage(
       "setBlock:", "blocks:", blocks.size(), "undo:", undo == null ? "null" : undo.getVolume());
   setBlock(playerName, blocks);
 }
示例#2
0
 @Override
 public void setBlock(String playerName, Collection<Block> blocks, boolean useUndo) {
   boolean direct = blocks.size() < 100;
   Message.debugMessage("Set Blocks:", blocks.size(), "direct:", direct);
   Clipboard undo = useUndo ? Clipboard.createUndoClipBoard(playerName) : null;
   blocks.forEach(
       block -> {
         if (undo != null) undo.add(block.getLevelBlock());
         setBlock(playerName, block, direct);
       });
   if (undo != null) getUndoManager().add(undo);
 }