Skip to content

Commit 96431c5

Browse files
committed
Change: Remove deprecated Minecraft, Mojang and Yggdrasil classes
1 parent 1396fab commit 96431c5

File tree

7 files changed

+18
-189
lines changed

7 files changed

+18
-189
lines changed

lib/dart_minecraft.dart

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,12 @@ export 'src/exceptions/auth_exception.dart';
44
export 'src/exceptions/ping_exception.dart';
55
export 'src/exceptions/too_many_requests_exception.dart';
66
export 'src/microsoft_api.dart';
7-
export 'src/minecraft.dart';
87
export 'src/minecraft/blocked_server.dart';
98
export 'src/minecraft/minecraft_news.dart';
109
export 'src/minecraft/minecraft_patch.dart';
1110
export 'src/minecraft/minecraft_statistics.dart';
1211
export 'src/minecraft/version_manifest.dart';
1312
export 'src/minecraft_api.dart';
14-
export 'src/mojang.dart';
1513
export 'src/mojang/mojang_status.dart';
1614
export 'src/mojang/name.dart';
1715
export 'src/mojang/profile.dart';
@@ -23,5 +21,4 @@ export 'src/packet/packets/server_packet.dart';
2321
export 'src/ping/server_ping_stub.dart'
2422
if (dart.library.io) 'src/ping/server_ping_io.dart';
2523
export 'src/utilities/pair.dart';
26-
export 'src/yggdrasil.dart';
2724
export 'src/yggdrasil_api.dart';

lib/src/minecraft.dart

Lines changed: 0 additions & 33 deletions
This file was deleted.

lib/src/mojang.dart

Lines changed: 0 additions & 94 deletions
This file was deleted.

lib/src/mojang/mojang_account.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1+
/// A JWT access token used for authentication in Minecraft.
2+
typedef AccessToken = String;
3+
14
/// A MojangAccount with data as returned by /authenticate.
25
class MojangAccount {
36
/// The access token used to access APIs and authenticate to Minecraft Servers.
47
///
58
/// This token is a replacement for logging in using a username and password each time,
69
/// so keep good track of it!
7-
String accessToken;
10+
AccessToken accessToken;
811

912
/// This account's client token.
1013
String clientToken;

lib/src/mojang_api.dart

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import 'exceptions/auth_exception.dart';
66
import 'exceptions/too_many_requests_exception.dart';
77
import 'minecraft/blocked_server.dart';
88
import 'minecraft/minecraft_statistics.dart';
9+
import 'mojang/mojang_account.dart';
910
import 'mojang/mojang_status.dart';
1011
import 'mojang/name.dart';
1112
import 'mojang/profile.dart';
@@ -126,7 +127,7 @@ Future<Profile> getProfile(String uuid) async {
126127

127128
/// Get's the Minecraft profile for the currently logged
128129
/// in user. This requires a valid access token.
129-
Future<Profile> getCurrentProfile(String accessToken) async {
130+
Future<Profile> getCurrentProfile(AccessToken accessToken) async {
130131
final response = await request(
131132
http.get, _minecraftServicesApi, 'minecraft/profile',
132133
headers: {
@@ -148,8 +149,8 @@ Future<Profile> getCurrentProfile(String accessToken) async {
148149
}
149150

150151
/// Changes the Mojang account name to [newName].
151-
Future<bool> changeName(
152-
String uuid, String newName, String accessToken, String password) async {
152+
Future<bool> changeName(String uuid, String newName, AccessToken accessToken,
153+
String password) async {
153154
final body = <String, String>{'name': newName, 'password': password};
154155
final headers = <String, String>{
155156
'authorization': 'Bearer $accessToken',
@@ -183,7 +184,7 @@ Future<bool> changeName(
183184

184185
/// Reserves the [newName] for this Mojang Account.
185186
// TODO: Improved return type including error message. Or just throw an error?
186-
Future<bool> reserveName(String newName, String accessToken) async {
187+
Future<bool> reserveName(String newName, AccessToken accessToken) async {
187188
final headers = {
188189
'authorization': 'Bearer $accessToken',
189190
'Origin': 'https://checkout.minecraft.net',
@@ -226,7 +227,7 @@ Future<bool> isNameAvailableNoAuth(String name) async {
226227
/// long and not include any invalid characters to be valid.
227228
/// If your access token is invalid, this will silently fail
228229
/// and return false.
229-
Future<bool> isNameAvailable(String name, String accessToken) async {
230+
Future<bool> isNameAvailable(String name, AccessToken accessToken) async {
230231
final response = await request(
231232
http.get, _minecraftServicesApi, 'minecraft/profile/name/$name/available',
232233
headers: {'authorization': 'Bearer $accessToken'});
@@ -241,7 +242,7 @@ Future<bool> isNameAvailable(String name, String accessToken) async {
241242
}
242243

243244
/// Reset's the player's skin.
244-
Future<void> resetSkin(String uuid, String accessToken) async {
245+
Future<void> resetSkin(String uuid, AccessToken accessToken) async {
245246
final headers = {
246247
'authorization': 'Bearer $accessToken',
247248
};
@@ -255,7 +256,7 @@ Future<void> resetSkin(String uuid, String accessToken) async {
255256
}
256257

257258
/// Change the skin with the texture of the skin at [skinUrl].
258-
Future<bool> changeSkin(Uri skinUrl, String accessToken,
259+
Future<bool> changeSkin(Uri skinUrl, AccessToken accessToken,
259260
[SkinModel skinModel = SkinModel.classic]) async {
260261
final headers = {
261262
'authorization': 'Bearer $accessToken',
@@ -311,7 +312,7 @@ Future<List<BlockedServer>> getBlockedServers() async {
311312
/// Checks whether or not the user has to answer the security challenges.
312313
/// This will return true if the current location is not verified and needs
313314
/// to be verified using [getSecurityChallenges] and [answerSecurityChallenges].
314-
Future<bool> areSecurityChallengesNeeded(String accessToken) async {
315+
Future<bool> areSecurityChallengesNeeded(AccessToken accessToken) async {
315316
final headers = {
316317
'authorization': 'Bearer $accessToken',
317318
};
@@ -324,7 +325,7 @@ Future<bool> areSecurityChallengesNeeded(String accessToken) async {
324325
/// to access the account.
325326
/// Check if this is needed using [areSecurityChallengesNeeded].
326327
Future<List<SecurityChallenge>> getSecurityChallenges(
327-
String accessToken) async {
328+
AccessToken accessToken) async {
328329
final headers = {
329330
'authorization': 'Bearer $accessToken',
330331
};
@@ -343,7 +344,7 @@ Future<List<SecurityChallenge>> getSecurityChallenges(
343344
/// You can get the security challenges through [getSecurityChallenges].
344345
/// Also check if this is needed using [areSecurityChallengesNeeded].
345346
Future<bool> answerSecurityChallenges(
346-
String accessToken, List<SecurityChallenge> answers) async {
347+
AccessToken accessToken, List<SecurityChallenge> answers) async {
347348
/// Verify we have enough answers passed.
348349
if (answers.length != 3) {
349350
throw ArgumentError.value(
@@ -369,7 +370,7 @@ Future<bool> answerSecurityChallenges(
369370
/// from a Mojang account to a Microsoft account. This function
370371
/// will simply return 'false' if the access token is invalid
371372
/// or expired.
372-
Future<bool> canMigrate(String accessToken) async {
373+
Future<bool> canMigrate(AccessToken accessToken) async {
373374
final response = await request(
374375
http.get, _minecraftServicesApi, 'rollout/v1/msamigration',
375376
headers: {

lib/src/yggdrasil.dart

Lines changed: 0 additions & 45 deletions
This file was deleted.

lib/src/yggdrasil_api.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ Future<MojangAccount> refresh(MojangAccount account) async {
9999
///
100100
/// [clientToken] is optional, though if provided should match the client token
101101
/// that was used to obtained given [accessToken].
102-
Future<bool> validate(String accessToken, {String? clientToken}) async {
102+
Future<bool> validate(AccessToken accessToken, {String? clientToken}) async {
103103
final headers = {
104104
'content-type': 'application/json',
105105
};
@@ -147,7 +147,7 @@ Future<bool> invalidate(MojangAccount mojangAccount) async {
147147
/// Be careful to what values you pass into [newPassword], as the [accessToken] will
148148
/// get invalidated and you will need it to log into your account again.
149149
Future<bool> changePassword(
150-
String currentPassword, String newPassword, String accessToken) async {
150+
String currentPassword, String newPassword, AccessToken accessToken) async {
151151
if (currentPassword.isEmpty) {
152152
throw ArgumentError.value(currentPassword, 'currentPassword',
153153
'The current password cannot be empty.');

0 commit comments

Comments
 (0)