mirror of
https://gitlab.com/2009scape/rt4-client.git
synced 2025-12-10 10:20:44 -07:00
Merge branch 'remembermylogin-plugin-multi-server' into 'master'
RememberMyLogin plugin: Save and load credentials based on the server hostname and port See merge request 2009scape/rt4-client!5
This commit is contained in:
commit
29f954e9b5
1 changed files with 13 additions and 6 deletions
|
|
@ -6,20 +6,25 @@ import plugin.api.API
|
|||
import rt4.Component
|
||||
import rt4.JagString
|
||||
import rt4.Player
|
||||
import rt4.client
|
||||
|
||||
@PluginMeta (
|
||||
author = "Ceikry",
|
||||
description = "Stores your last used login for automatic reuse",
|
||||
version = 1.0
|
||||
description = "Stores your last used login for automatic reuse, per server",
|
||||
version = 1.1
|
||||
)
|
||||
class plugin : Plugin() {
|
||||
var hasRan = false
|
||||
var credentials = HashMap<String, HashMap<String, String>>()
|
||||
var server = ""
|
||||
var username = ""
|
||||
var password = ""
|
||||
|
||||
override fun Init() {
|
||||
username = API.GetData("login-user") as? String ?: ""
|
||||
password = API.GetData("login-pass") as? String ?: ""
|
||||
server = client.hostname + ":" + client.port
|
||||
credentials = API.GetData("login-credentials") as? HashMap<String, HashMap<String, String>> ?: HashMap()
|
||||
username = credentials.get(server)?.get("username") ?: ""
|
||||
password = credentials.get(server)?.get("password") ?: ""
|
||||
}
|
||||
|
||||
override fun ComponentDraw(componentIndex: Int, component: Component?, screenX: Int, screenY: Int) {
|
||||
|
|
@ -34,8 +39,10 @@ class plugin : Plugin() {
|
|||
override fun OnLogin() {
|
||||
username = String(Player.usernameInput.chars)
|
||||
password = String(Player.password.chars)
|
||||
API.StoreData("login-user", username)
|
||||
API.StoreData("login-pass", password)
|
||||
|
||||
credentials[server] = mapOf("username" to username, "password" to password) as HashMap<String, String>
|
||||
|
||||
API.StoreData("login-credentials", credentials)
|
||||
}
|
||||
|
||||
override fun OnLogout() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue