Пример #1
0
  public static boolean unClaimChunk(Kingdom kingdom, Player player) {
    Chunk chunk = player.getLocation().getChunk();

    if (isClaimed(chunk)) {
      try {
        java.sql.PreparedStatement s =
            QuartzKingdoms.DBKing.prepareStatement(
                "DELETE FROM Chunks WHERE X=? AND Z=? AND kingdom_id=?;");
        s.setInt(1, chunk.getX());
        s.setInt(2, chunk.getZ());
        s.setInt(3, kingdom.getID());
        s.executeUpdate();
        return true;
      } catch (SQLException e) {
        KUtil.printException("Failed to delete chunks from database", e);
        return false;
      }
    } else {
      return false;
    }
  }
Пример #2
0
  public static boolean claimChunk(Kingdom kingdom, Player player) {
    Chunk chunk = player.getLocation().getChunk();

    if (!isClaimed(chunk)) {
      // claim chunk
      try {
        java.sql.PreparedStatement s =
            QuartzKingdoms.DBKing.prepareStatement(
                "INSERT INTO Chunks (kingdom_id, X, Z) VALUES (?, ?, ?);");
        s.setInt(1, kingdom.getID());
        s.setInt(2, chunk.getX());
        s.setInt(3, chunk.getZ());
        s.executeUpdate();
        return true;
      } catch (SQLException e) {
        e.printStackTrace();
        return false;
      }
    } else {
      return false;
    }
  }