- Location bedLoc = SQLHelper.selectHomeLocByHomeId(con, uuid, homeId, BedPartConstants.FOOT);
- if (Objects.isNull(bedLoc)) {
- MessageUtils.sendMessage(sender, ConfigConstants.TP + "." + ConfigConstants.FAIL);
- return;
- }
查询部分
- @Contract("_, _, _, _ -> new")
- public static @Nullable Location selectHomeLocByHomeId(@NotNull Connection con, String uuid, int homeId, String bedPart) throws SQLException {
- // System.out.println("select");
- String sql = "select * from BEDHOMES where uuid = '" + uuid + "' AND homeId = " + homeId + " AND part = '" + bedPart + "'";
- return selectLocation(con, sql);
- }
- private static @Nullable Location selectLocation(@NotNull Connection con, String sql) throws SQLException {
- ResultSet rs;
- Statement pst;
- pst = con.createStatement();
- rs = pst.executeQuery(sql);
- try {
- return new Location(Bukkit.getWorld(rs.getString("world")), rs.getInt("x"), rs.getInt("y"), rs.getInt("z"));
- } catch (SQLException e) {
- // e.printStackTrace();
- return null;
- }
- }
找到了,是@Contract注解的问题