mirror of
https://gitlab.com/2009scape/rt4-client.git
synced 2025-12-11 09:00:26 -07:00
RememberMyLogin plugin: Save and load credentials based on the server hostname and port
This commit is contained in:
parent
150a7885dc
commit
df22cb8a98
1 changed files with 13 additions and 6 deletions
|
|
@ -6,20 +6,25 @@ import plugin.api.API
|
||||||
import rt4.Component
|
import rt4.Component
|
||||||
import rt4.JagString
|
import rt4.JagString
|
||||||
import rt4.Player
|
import rt4.Player
|
||||||
|
import rt4.client
|
||||||
|
|
||||||
@PluginMeta (
|
@PluginMeta (
|
||||||
author = "Ceikry",
|
author = "Ceikry",
|
||||||
description = "Stores your last used login for automatic reuse",
|
description = "Stores your last used login for automatic reuse, per server",
|
||||||
version = 1.0
|
version = 1.1
|
||||||
)
|
)
|
||||||
class plugin : Plugin() {
|
class plugin : Plugin() {
|
||||||
var hasRan = false
|
var hasRan = false
|
||||||
|
var credentials = HashMap<String, HashMap<String, String>>()
|
||||||
|
var server = ""
|
||||||
var username = ""
|
var username = ""
|
||||||
var password = ""
|
var password = ""
|
||||||
|
|
||||||
override fun Init() {
|
override fun Init() {
|
||||||
username = API.GetData("login-user") as? String ?: ""
|
server = client.hostname + ":" + client.port
|
||||||
password = API.GetData("login-pass") as? String ?: ""
|
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) {
|
override fun ComponentDraw(componentIndex: Int, component: Component?, screenX: Int, screenY: Int) {
|
||||||
|
|
@ -34,8 +39,10 @@ class plugin : Plugin() {
|
||||||
override fun OnLogin() {
|
override fun OnLogin() {
|
||||||
username = String(Player.usernameInput.chars)
|
username = String(Player.usernameInput.chars)
|
||||||
password = String(Player.password.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() {
|
override fun OnLogout() {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue