Skip to content

Commit

Permalink
Support 0.8.6 IR jars without breaking backwards compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
seraxis committed Dec 4, 2023
1 parent 9b5b282 commit 7750aad
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 17 deletions.
20 changes: 15 additions & 5 deletions core/src/bms/player/beatoraja/MainController.java
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,21 @@ public MainController(Path f, Config config, PlayerConfig player, BMSPlayerMode
if(ir != null) {
if(irconfig.getUserid().length() == 0 || irconfig.getPassword().length() == 0) {
} else {
IRResponse<IRPlayerData> response = ir.login(irconfig.getUserid(), irconfig.getPassword());
if(response.isSucceeded()) {
irarray.add(new IRStatus(irconfig, ir, response.getData()));
} else {
Logger.getGlobal().warning("IRへのログイン失敗 : " + response.getMessage());
try {
IRResponse<IRPlayerData> response = ir.login(new IRAccount(irconfig.getUserid(), irconfig.getPassword(), ""));
if(response.isSucceeded()) {
irarray.add(new IRStatus(irconfig, ir, response.getData()));
} else {
Logger.getGlobal().warning("IRへのログイン失敗 : " + response.getMessage());
}
} catch (IllegalArgumentException e) {
Logger.getGlobal().info("trying pre-0.8.5 IR login method");
IRResponse<IRPlayerData> response = ir.login(irconfig.getUserid(), irconfig.getPassword());
if(response.isSucceeded()) {
irarray.add(new IRStatus(irconfig, ir, response.getData()));
} else {
Logger.getGlobal().warning("IRへのログイン失敗 : " + response.getMessage());
}
}
}
}
Expand Down
24 changes: 24 additions & 0 deletions core/src/bms/player/beatoraja/ir/IRAccount.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package bms.player.beatoraja.ir;

public class IRAccount {

/**
* プレイヤーID
*/
public final String id;
/**
* パスワード
*/
public final String password;
/**
* プレイヤー名
*/
public final String name;

public IRAccount(String id, String password, String name) {
this.id = id;
this.password = password;
this.name = name;
}

}
30 changes: 18 additions & 12 deletions core/src/bms/player/beatoraja/ir/IRConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,31 @@ public interface IRConnection {
/**
* IRに新規ユーザー登録する。
*
* @param id
* ユーザーID
* @param pass
* パスワード
* @param name
* ユーザー名
* @param accout
* アカウント情報
* @return
*/
public IRResponse<IRPlayerData> register(String id, String pass, String name);
default public IRResponse<IRPlayerData> register(IRAccount account) {
throw new IllegalArgumentException("Use of this function with this signature without providing an implementation is not permitted");
};

default public IRResponse<IRPlayerData> register(String id, String pass, String name) {
throw new IllegalArgumentException("Use of this function with this signature without providing an implementation is not permitted");
};

/**
* IRにログインする。起動時に呼び出される
*
* @param id
* ユーザーID
* @param pass
* パスワード
* @param accout
* アカウント情報
* @return
*/
public IRResponse<IRPlayerData> login(String id, String pass);
default public IRResponse<IRPlayerData> login(IRAccount account) {
throw new IllegalArgumentException("Use of this function with this signature without providing an implementation is not permitted");
};
default public IRResponse<IRPlayerData> login(String id, String pass) {
throw new IllegalArgumentException("Use of this function with this signature without providing an implementation is not permitted");
};

/**
* ライバルデータを収録する
Expand Down

0 comments on commit 7750aad

Please sign in to comment.