Пример #1
0
  public static void deleteBookmark(L1PcInstance player, String s) {
    L1BookMark book = player.getBookMark(s);
    if (book != null) {
      Connection con = null;
      PreparedStatement pstm = null;
      try {

        con = L1DatabaseFactory.getInstance().getConnection();
        pstm = con.prepareStatement("DELETE FROM character_teleport WHERE id=?");
        pstm.setInt(1, book.getId());
        pstm.execute();
        player.removeBookMark(book);
      } catch (SQLException e) {
        _log.log(Level.SEVERE, "ブックマークの削除でエラーが発生しました。", e);
      } finally {
        SQLUtil.close(pstm);
        SQLUtil.close(con);
      }
    }
  }
Пример #2
0
  public static void addBookmark(L1PcInstance pc, String s) {
    // クライアント側でチェックされるため不要
    //		if (s.length() > 12) {
    //			pc.sendPackets(new S_ServerMessage(204));
    //			return;
    //		}

    if (!pc.getMap().isMarkable()) {
      pc.sendPackets(new S_ServerMessage(214)); // \f1ここを記憶することができません。
      return;
    }

    int size = pc.getBookMarkSize();
    if (size > 49) {
      return;
    }

    if (pc.getBookMark(s) == null) {
      L1BookMark bookmark = new L1BookMark();
      bookmark.setId(IdFactory.getInstance().nextId());
      bookmark.setCharId(pc.getId());
      bookmark.setName(s);
      bookmark.setLocX(pc.getX());
      bookmark.setLocY(pc.getY());
      bookmark.setMapId(pc.getMapId());

      Connection con = null;
      PreparedStatement pstm = null;

      try {
        con = L1DatabaseFactory.getInstance().getConnection();
        pstm =
            con.prepareStatement(
                "INSERT INTO character_teleport SET id = ?, char_id = ?, name = ?, locx = ?, locy = ?, mapid = ?");
        pstm.setInt(1, bookmark.getId());
        pstm.setInt(2, bookmark.getCharId());
        pstm.setString(3, bookmark.getName());
        pstm.setInt(4, bookmark.getLocX());
        pstm.setInt(5, bookmark.getLocY());
        pstm.setInt(6, bookmark.getMapId());
        pstm.execute();
      } catch (SQLException e) {
        _log.log(Level.SEVERE, "ブックマークの追加でエラーが発生しました。", e);
      } finally {
        SQLUtil.close(pstm);
        SQLUtil.close(con);
      }

      pc.addBookMark(bookmark);
      pc.sendPackets(
          new S_Bookmarks(
              s, bookmark.getMapId(), bookmark.getId(), bookmark.getLocX(), bookmark.getLocY()));
    } else {
      pc.sendPackets(new S_ServerMessage(327)); // 同じ名前がすでに存在しています。
    }
  }