mirror of
https://gitlab.com/2009scape/rt4-client.git
synced 2025-12-15 02:50:23 -07:00
cleanup
This commit is contained in:
parent
9cb152a3c1
commit
f0de95ad06
1 changed files with 8 additions and 6 deletions
|
|
@ -99,6 +99,8 @@ class plugin : Plugin() {
|
|||
|
||||
private fun replace() {
|
||||
if (component != null && component?.id == TARGET_COMPONENT_ID) {
|
||||
// Unmodified login name is used here to display it however the user types it
|
||||
// caps and spaces respected.
|
||||
val modifiedStr = replaceUsernameInBytes(component!!.text.chars, Player.usernameInput.toString())
|
||||
component?.text = JagString.parse(modifiedStr)
|
||||
}
|
||||
|
|
@ -124,11 +126,11 @@ class plugin : Plugin() {
|
|||
}
|
||||
|
||||
// No match found, check the hiscores (live server)
|
||||
fetchAccountTypeFromAPI(cleanUsername)
|
||||
fetchAccountTypeFromAPI(lowercaseUsername)
|
||||
}
|
||||
|
||||
private fun fetchAccountTypeFromAPI(username : String){
|
||||
val apiUrl = "http://api.2009scape.org:3000/hiscores/playerSkills/1/${username.toLowerCase()}"
|
||||
private fun fetchAccountTypeFromAPI(lowercaseUsername : String){
|
||||
val apiUrl = "http://api.2009scape.org:3000/hiscores/playerSkills/1/${lowercaseUsername}"
|
||||
Thread {
|
||||
try {
|
||||
val url = URL(apiUrl)
|
||||
|
|
@ -144,16 +146,16 @@ class plugin : Plugin() {
|
|||
val reader = BufferedReader(InputStreamReader(connection.inputStream))
|
||||
val response = reader.use { it.readText() }
|
||||
reader.close()
|
||||
updatePlayerData(response, username)
|
||||
updatePlayerData(response, lowercaseUsername)
|
||||
}
|
||||
} catch (_: Exception) { }
|
||||
}.start()
|
||||
}
|
||||
|
||||
private fun updatePlayerData(jsonResponse: String, username: String) {
|
||||
private fun updatePlayerData(jsonResponse: String, lowercaseUsername: String) {
|
||||
val hiscoresResponse = gson.fromJson(jsonResponse, HiscoresResponse::class.java)
|
||||
ACCOUNT_TYPE = hiscoresResponse.info.iron_mode.toInt()
|
||||
usernameMatches[username.toLowerCase()] = ACCOUNT_TYPE
|
||||
usernameMatches[lowercaseUsername] = ACCOUNT_TYPE
|
||||
storeData()
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue