public static void editBBSThread(
     MapleClient client, String title, String text, int icon, int localthreadid) {
   MapleCharacter c = client.getPlayer();
   if (c.getGuildId() <= 0) {
     return; // expelled while viewing?
   }
   try {
     Connection con = DatabaseConnection.getConnection();
     PreparedStatement ps =
         con.prepareStatement(
             "UPDATE bbs_threads SET "
                 + "`name` = ?, "
                 + "`timestamp` = ?, "
                 + "`icon` = ?, "
                 + "`startpost` = ? "
                 + "WHERE guildid = ? AND localthreadid = ? AND (postercid = ? OR ?)");
     ps.setString(1, title);
     ps.setLong(2, System.currentTimeMillis());
     ps.setInt(3, icon);
     ps.setString(4, text);
     ps.setInt(5, c.getGuildId());
     ps.setInt(6, localthreadid);
     ps.setInt(7, c.getId());
     ps.setBoolean(8, c.getGuildRank() <= 2);
     ps.execute();
     ps.close();
     displayThread(client, localthreadid);
   } catch (SQLException se) {
     log.error("SQLException: " + se.getLocalizedMessage(), se);
   }
 }
  public static void deleteBBSReply(MapleClient client, int replyid) {
    MapleCharacter mc = client.getPlayer();
    if (mc.getGuildId() <= 0) {
      return;
    }

    int threadid;
    Connection con = DatabaseConnection.getConnection();
    try {
      PreparedStatement ps =
          con.prepareStatement("SELECT postercid, threadid FROM bbs_replies WHERE replyid = ?");
      ps.setInt(1, replyid);
      ResultSet rs = ps.executeQuery();
      if (!rs.next()) {
        rs.close();
        ps.close();
        return; // reply no longer exists, deleted already?
      }
      if (mc.getId() != rs.getInt("postercid") && mc.getGuildRank() > 2) {
        rs.close();
        ps.close();
        return; // [hax] deleting a reply that he didn't make
      }
      threadid = rs.getInt("threadid");
      rs.close();
      ps.close();

      ps = con.prepareStatement("DELETE FROM bbs_replies WHERE replyid = ?");
      ps.setInt(1, replyid);
      ps.execute();
      ps.close();

      ps =
          con.prepareStatement(
              "UPDATE bbs_threads SET replycount = replycount - 1 WHERE threadid = ?");
      ps.setInt(1, threadid);
      ps.execute();
      ps.close();
      displayThread(client, threadid, false);
    } catch (SQLException se) {
      log.error("SQLException: " + se.getLocalizedMessage(), se);
    }
  }
  public static void deleteBBSThread(MapleClient client, int localthreadid) {
    MapleCharacter mc = client.getPlayer();
    if (mc.getGuildId() <= 0) {
      return;
    }

    Connection con = DatabaseConnection.getConnection();
    try {
      PreparedStatement ps =
          con.prepareStatement(
              "SELECT threadid, postercid FROM bbs_threads WHERE guildid = ? AND localthreadid = ?");
      ps.setInt(1, mc.getGuildId());
      ps.setInt(2, localthreadid);
      ResultSet threadRS = ps.executeQuery();
      if (!threadRS.next()) {
        threadRS.close();
        ps.close();
        return; // thread no longer exists, deleted?
      }
      if (mc.getId() != threadRS.getInt("postercid") && mc.getGuildRank() > 2) {
        threadRS.close();
        ps.close();
        return; // [hax] deleting a thread that he didn't make
      }
      int threadid = threadRS.getInt("threadid");
      threadRS.close();
      ps.close();

      ps = con.prepareStatement("DELETE FROM bbs_replies WHERE threadid = ?");
      ps.setInt(1, threadid);
      ps.execute();
      ps.close();

      ps = con.prepareStatement("DELETE FROM bbs_threads WHERE threadid = ?");
      ps.setInt(1, threadid);
      ps.execute();
      ps.close();
    } catch (SQLException se) {
      log.error("SQLException: " + se.getLocalizedMessage(), se);
    }
  }