/** * Draw the chess piece represented by stone into the given row and column. The actual blocks * drawn depend on the board's current chess set. * * @param row * @param col * @param stone */ public void paintChessPiece(int row, int col, int stone) { // for entity sets, just check that the entity is still at (row,col) // for block sets, get the stone and paste its data into the region at (row,col) ChessSet cSet = designer != null ? designer.getChessSet() : chessSet; if (cSet.hasMovablePieces()) { // we don't paint movable pieces; moveChessPiece() can handle those return; } Cuboid region = getPieceRegion(row, col); MassBlockUpdate mbu = CraftMassBlockUpdate.createMassBlockUpdater( ChessCraft.getInstance(), getBoard().getWorld()); region.fill(0, (byte) 0, mbu); if (stone != Chess.NO_STONE) { ChessStone cStone = cSet.getStone(stone, getRotation()); if (cStone != null) { cStone.paint(region, mbu); } else { LogUtils.severe("unknown chess stone " + stone); } } region.expand(CuboidDirection.Down, 1).forceLightLevel(boardStyle.getLightLevel()); mbu.notifyClients(); if (ChessCraft.getInstance().getDynmapIntegration() != null) { ChessCraft.getInstance().getDynmapIntegration().triggerUpdate(region); } }
public static void save(SMSPersistable object) { File saveFile = new File(object.getSaveFolder(), object.getName() + ".yml"); YamlConfiguration conf = new YamlConfiguration(); Map<String, Object> map = object.freeze(); expandMapIntoConfig(conf, map); try { conf.save(saveFile); } catch (IOException e) { LogUtils.severe("Can't save " + saveFile + ": " + e.getMessage()); } }
public static boolean reload(BoardView view) { boolean restored = false; try { TerrainManager tm = new TerrainManager(ChessCraft.getWorldEdit(), view.getA1Square().getWorld()); tm.loadSchematic(new File(DirectoryStructure.getSchematicsDirectory(), view.getName())); restored = true; } catch (Exception e) { LogUtils.warning(e.getMessage()); } return restored; }
@Override public void run() { Debugger.getInstance().debug("database writer thread starting"); while (true) { try { DatabaseSavable savable = handler.pollDatabaseUpdate(); // block until there's a record available if (savable instanceof Results.EndMarker) { break; } Connection conn = handler.getDBConnection(); if (conn != null) { savable.saveToDatabase(conn); } } catch (InterruptedException e) { LogUtils.warning("interrupted while saving database results"); e.printStackTrace(); } catch (SQLException e) { LogUtils.warning("failed to save results record to database: " + e.getMessage()); } } Debugger.getInstance().debug("database writer thread exiting"); }
public static boolean save(BoardView view) { boolean saved = false; try { TerrainManager tm = new TerrainManager(ChessCraft.getWorldEdit(), view.getA1Square().getWorld()); Cuboid c = view.getOuterBounds(); Location l1 = c.getLowerNE(); Location l2 = c.getUpperSW(); tm.saveTerrain(new File(DirectoryStructure.getSchematicsDirectory(), view.getName()), l1, l2); saved = true; } catch (Exception e) { LogUtils.warning(e.getMessage()); } return saved; }
/** * Draw the chess piece represented by stone into the given row and column. The actual blocks * drawn depend on the board's current chess set. * * @param row * @param col * @param stone */ public void paintChessPiece(int row, int col, int stone) { Cuboid region = getPieceRegion(row, col); MassBlockUpdate mbu = CraftMassBlockUpdate.createMassBlockUpdater(getBoard().getWorld()); region.fill(0, (byte) 0, mbu); ChessSet cSet = designer != null ? designer.getChessSet() : chessPieceSet; if (stone != Chess.NO_STONE) { ChessStone cStone = cSet.getStone(stone, getRotation()); if (cStone != null) { paintChessPiece(region, cStone, mbu); } else { LogUtils.severe("unknown piece: " + stone); } } region.expand(CuboidDirection.Down, 1).forceLightLevel(boardStyle.getLightLevel()); mbu.notifyClients(); }
public static void loadMenus() { MenuManager mm = ScrollingMenuSign.getInstance().getMenuManager(); for (SMSMenu menu : mm.listMenus()) { menu.deleteTemporary(); } for (File f : DirectoryStructure.getMenusFolder().listFiles(ymlFilter)) { try { Debugger.getInstance().debug(2, "loading menu: " + f); YamlConfiguration conf = YamlConfiguration.loadConfiguration(f); SMSMenu menu = new SMSMenu(conf); mm.registerMenu(menu.getName(), menu); menu.notifyObservers(); } catch (SMSException e) { LogUtils.severe("Can't load menu data from " + f + ": " + e.getMessage()); } } Debugger.getInstance().debug("Loaded " + mm.listMenus().size() + " menus from file."); }
public static void unPersist(SMSPersistable object) { File saveFile = new File(object.getSaveFolder(), object.getName() + ".yml"); if (!saveFile.delete()) { LogUtils.warning("can't delete " + saveFile); } }