Make this project work again
This commit is contained in:
4 files changed
+85
-3
No files matched your search
@@ -10,9 +10,22 @@
|
||||
1FF5C7852F73B80400A92689 /* Berry Leaderboards.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Berry Leaderboards.app"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFileSystemSynchronizedBuildFileExceptionSet section */
|
||||
1FF5C79B2F73B96100A92689 /* Exceptions for "Berry Leaderboards" folder in "Berry Leaderboards" target */ = {
|
||||
isa = PBXFileSystemSynchronizedBuildFileExceptionSet;
|
||||
membershipExceptions = (
|
||||
"Berry-Leaderboards-Info.plist",
|
||||
);
|
||||
target = 1FF5C7842F73B80400A92689 /* Berry Leaderboards */;
|
||||
};
|
||||
/* End PBXFileSystemSynchronizedBuildFileExceptionSet section */
|
||||
|
||||
/* Begin PBXFileSystemSynchronizedRootGroup section */
|
||||
1FF5C7872F73B80400A92689 /* Berry Leaderboards */ = {
|
||||
isa = PBXFileSystemSynchronizedRootGroup;
|
||||
exceptions = (
|
||||
1FF5C79B2F73B96100A92689 /* Exceptions for "Berry Leaderboards" folder in "Berry Leaderboards" target */,
|
||||
);
|
||||
path = "Berry Leaderboards";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
@@ -256,9 +269,20 @@
|
||||
DEVELOPMENT_TEAM = 265636CTKR;
|
||||
ENABLE_APP_SANDBOX = YES;
|
||||
ENABLE_HARDENED_RUNTIME = YES;
|
||||
ENABLE_INCOMING_NETWORK_CONNECTIONS = NO;
|
||||
ENABLE_OUTGOING_NETWORK_CONNECTIONS = YES;
|
||||
ENABLE_PREVIEWS = YES;
|
||||
ENABLE_RESOURCE_ACCESS_AUDIO_INPUT = NO;
|
||||
ENABLE_RESOURCE_ACCESS_BLUETOOTH = NO;
|
||||
ENABLE_RESOURCE_ACCESS_CALENDARS = NO;
|
||||
ENABLE_RESOURCE_ACCESS_CAMERA = NO;
|
||||
ENABLE_RESOURCE_ACCESS_CONTACTS = NO;
|
||||
ENABLE_RESOURCE_ACCESS_LOCATION = NO;
|
||||
ENABLE_RESOURCE_ACCESS_PRINTING = NO;
|
||||
ENABLE_RESOURCE_ACCESS_USB = NO;
|
||||
ENABLE_USER_SELECTED_FILES = readonly;
|
||||
GENERATE_INFOPLIST_FILE = YES;
|
||||
INFOPLIST_FILE = "Berry-Leaderboards-Info.plist";
|
||||
INFOPLIST_KEY_NSHumanReadableCopyright = "";
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
@@ -288,9 +312,20 @@
|
||||
DEVELOPMENT_TEAM = 265636CTKR;
|
||||
ENABLE_APP_SANDBOX = YES;
|
||||
ENABLE_HARDENED_RUNTIME = YES;
|
||||
ENABLE_INCOMING_NETWORK_CONNECTIONS = NO;
|
||||
ENABLE_OUTGOING_NETWORK_CONNECTIONS = YES;
|
||||
ENABLE_PREVIEWS = YES;
|
||||
ENABLE_RESOURCE_ACCESS_AUDIO_INPUT = NO;
|
||||
ENABLE_RESOURCE_ACCESS_BLUETOOTH = NO;
|
||||
ENABLE_RESOURCE_ACCESS_CALENDARS = NO;
|
||||
ENABLE_RESOURCE_ACCESS_CAMERA = NO;
|
||||
ENABLE_RESOURCE_ACCESS_CONTACTS = NO;
|
||||
ENABLE_RESOURCE_ACCESS_LOCATION = NO;
|
||||
ENABLE_RESOURCE_ACCESS_PRINTING = NO;
|
||||
ENABLE_RESOURCE_ACCESS_USB = NO;
|
||||
ENABLE_USER_SELECTED_FILES = readonly;
|
||||
GENERATE_INFOPLIST_FILE = YES;
|
||||
INFOPLIST_FILE = "Berry-Leaderboards-Info.plist";
|
||||
INFOPLIST_KEY_NSHumanReadableCopyright = "";
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
|
||||
@@ -76,7 +76,7 @@ struct ContentView: View {
|
||||
}
|
||||
|
||||
func loadLeaderboard() async throws -> [Player] {
|
||||
let url = URL(string: "https://berrydash.lncvrt.xyz/database/getTopPlayersAPI.php")!
|
||||
let url = URL(string: "https://games.lncvrt.xyz/api/berrydash/leaderboard/score")!
|
||||
let (data, _) = try await URLSession.shared.data(from: url)
|
||||
guard let raw = String(data: data, encoding: .utf8) else { return [] }
|
||||
return parseLeaderboard(raw)
|
||||
|
||||
@@ -7,12 +7,54 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
struct LeaderboardResponse: Codable {
|
||||
let success: Bool
|
||||
let message: String?
|
||||
let data: [PlayerData]
|
||||
}
|
||||
|
||||
struct PlayerData: Codable {
|
||||
let id: Int
|
||||
let username: String
|
||||
let value: Int
|
||||
let icon: IntOrString
|
||||
let overlay: IntOrString
|
||||
let birdColor: [Int]
|
||||
let overlayColor: [Int]
|
||||
let customIcon: String?
|
||||
}
|
||||
|
||||
enum IntOrString: Codable {
|
||||
case int(Int)
|
||||
case string(String)
|
||||
|
||||
init(from decoder: Decoder) throws {
|
||||
let container = try decoder.singleValueContainer()
|
||||
if let int = try? container.decode(Int.self) {
|
||||
self = .int(int)
|
||||
} else if let str = try? container.decode(String.self) {
|
||||
self = .string(str)
|
||||
} else {
|
||||
throw DecodingError.dataCorrupted(.init(codingPath: decoder.codingPath, debugDescription: "Invalid value"))
|
||||
}
|
||||
}
|
||||
|
||||
func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.singleValueContainer()
|
||||
switch self {
|
||||
case .int(let i): try container.encode(i)
|
||||
case .string(let s): try container.encode(s)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct Player: Codable {
|
||||
let username: String
|
||||
let score: Int
|
||||
}
|
||||
|
||||
func parseLeaderboard(_ raw: String) -> [Player] {
|
||||
guard let data = raw.data(using: .utf8) else { return [] }
|
||||
return (try? JSONDecoder().decode([Player].self, from: data)) ?? []
|
||||
guard let data = raw.data(using: .utf8) else { return [] }
|
||||
guard let response = try? JSONDecoder().decode(LeaderboardResponse.self, from: data) else { return [] }
|
||||
return response.data.map { Player(username: $0.username, score: $0.value) }
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict/>
|
||||
</plist>
|
||||
Reference in new issue
Block a user