凌语丶
  1. Location bedLoc = SQLHelper.selectHomeLocByHomeId(con, uuid, homeId, BedPartConstants.FOOT);
  2.             if (Objects.isNull(bedLoc)) {
  3.                 MessageUtils.sendMessage(sender, ConfigConstants.TP + "." + ConfigConstants.FAIL);
  4.                 return;
  5.             }
复制代码
IDE警告:条件 'Objects.isNull(bedLoc)' 始终为 'false'

查询部分
  1.     @Contract("_, _, _, _ -> new")
  2.     public static @Nullable Location selectHomeLocByHomeId(@NotNull Connection con, String uuid, int homeId, String bedPart) throws SQLException {
  3.         // System.out.println("select");
  4.         String sql = "select * from BEDHOMES where uuid = '" + uuid + "' AND homeId = " + homeId + " AND part = '" + bedPart + "'";
  5.         return selectLocation(con, sql);
  6.     }

  7.     private static @Nullable Location selectLocation(@NotNull Connection con, String sql) throws SQLException {
  8.         ResultSet rs;
  9.         Statement pst;
  10.         pst = con.createStatement();
  11.         rs = pst.executeQuery(sql);
  12.         try {
  13.             return new Location(Bukkit.getWorld(rs.getString("world")), rs.getInt("x"), rs.getInt("y"), rs.getInt("z"));
  14.         } catch (SQLException e) {
  15.             // e.printStackTrace();
  16.             return null;
  17.         }
  18.     }
复制代码



凌语丶
找到了,是@Contract注解的问题

第一页 上一页 下一页 最后一页