diff options
author | Soopyboo32 <49228220+Soopyboo32@users.noreply.github.com> | 2021-11-07 19:24:47 +0800 |
---|---|---|
committer | Soopyboo32 <49228220+Soopyboo32@users.noreply.github.com> | 2021-11-07 19:24:47 +0800 |
commit | e44de4dc2876d771d871255e72c6884b958c05eb (patch) | |
tree | 26bbc40b5a94072f1bd73c4bd472687e1cd62ef5 /features | |
parent | fb19a8b072e8529b9d90bd3fb322da31ca4911df (diff) | |
download | SoopyV2-e44de4dc2876d771d871255e72c6884b958c05eb.tar.gz SoopyV2-e44de4dc2876d771d871255e72c6884b958c05eb.tar.bz2 SoopyV2-e44de4dc2876d771d871255e72c6884b958c05eb.zip |
add apikey menu to first load
Diffstat (limited to 'features')
-rw-r--r-- | features/agentlaiThings/hiddenRequirement.js | 4 | ||||
-rw-r--r-- | features/cosmetics/hiddenRequirement.js | 7 | ||||
-rw-r--r-- | features/cosmetics/index.js | 5 | ||||
-rw-r--r-- | features/globalSettings/firstLoadPages.js | 32 | ||||
-rw-r--r-- | features/globalSettings/index.js | 169 | ||||
-rw-r--r-- | features/settings/index.js | 2 |
6 files changed, 198 insertions, 21 deletions
diff --git a/features/agentlaiThings/hiddenRequirement.js b/features/agentlaiThings/hiddenRequirement.js index 3c0408d..effd23b 100644 --- a/features/agentlaiThings/hiddenRequirement.js +++ b/features/agentlaiThings/hiddenRequirement.js @@ -3,6 +3,6 @@ let allowedUUIDS = [ "dc8c39647b294e03ae9ed13ebd65dd29" ] -export default ()=>{ +module.exports = {hidden: function(featureManager){ return !allowedUUIDS.includes(Player.getUUID().toString().replace(/-/g, "")) -}
\ No newline at end of file +}}
\ No newline at end of file diff --git a/features/cosmetics/hiddenRequirement.js b/features/cosmetics/hiddenRequirement.js index 7e0b57a..dbc3e06 100644 --- a/features/cosmetics/hiddenRequirement.js +++ b/features/cosmetics/hiddenRequirement.js @@ -1,5 +1,4 @@ -let cosmeticsClass = require("./index").class -export default ()=>{ - return !!cosmeticsClass?.cosmeticsData?.[Player.getUUID().toString()] -}
\ No newline at end of file +module.exports = {hidden: function(featureManager){ + return !(featureManager.features.cosmetics?.["class"]?.playerHasACosmeticA || false) +}}
\ No newline at end of file diff --git a/features/cosmetics/index.js b/features/cosmetics/index.js index 593ac7c..11d9f47 100644 --- a/features/cosmetics/index.js +++ b/features/cosmetics/index.js @@ -16,6 +16,8 @@ class Cosmetics extends Feature { this.cosmeticsData = {} + this.playerHasACosmeticA = false + this.firstPersonVisable = new Toggle("Cosmetics visable in first person", "", false, "cosmetics_first_person_visable", this) this.lessFirstPersonVisable = new Toggle("Make cosmetics less visable in first person mode", "", true, "cosmetics_first_person_less_visable", this).requires(this.firstPersonVisable) @@ -38,6 +40,7 @@ class Cosmetics extends Feature { let data = JSON.parse(FileLib.getUrlContent("http://soopymc.my.to/api/soopyv2/cosmetics.json")) this.cosmeticsData = data + this.playerHasACosmeticA = !!data[Player.getUUID().toString()] this.scanForNewCosmetics() } @@ -88,6 +91,7 @@ class Cosmetics extends Feature { if(this.shouldPlayerHaveCosmetic(player, "dragon_wings") && !this.uuidToCosmetic[player.getUUID().toString()]){ let cosmetic = new DragonWings(player, this) + this.playerHasACosmeticA = true this.loadedCosmetics.push(cosmetic) this.uuidToCosmetic[player.getUUID().toString()] = cosmetic } @@ -134,6 +138,7 @@ class Cosmetics extends Feature { initVariables(){ this.loadedCosmetics = undefined this.uuidToCosmetic = undefined + this.playerHasACosmeticA = undefined } onDisable(){ diff --git a/features/globalSettings/firstLoadPages.js b/features/globalSettings/firstLoadPages.js index c7a90f0..e395afe 100644 --- a/features/globalSettings/firstLoadPages.js +++ b/features/globalSettings/firstLoadPages.js @@ -13,6 +13,7 @@ class WelcomePage extends FirstLoadPage{ this.addChild(new SoopyTextElement().setText("§7First lets get privacy settings out of the way.").setLocation(0.1, 0.15,0.8,0.075).setMaxTextScale(10)); this.settingsArea = new SoopyGuiElement().setLocation(0.1, 0.25,0.8,0.75); + this.settingsArea.setScrollable(true) this.addChild(this.settingsArea); } @@ -31,6 +32,35 @@ class WelcomePage extends FirstLoadPage{ }) } } +class ApiKeyPage extends FirstLoadPage{ + constructor(){ + super() + + this.addChild(new SoopyTextElement().setText("§0Next lets setup your api key!").setLocation(0.1, 0.05,0.8,0.1).setMaxTextScale(10)); + + this.addChild(new SoopyTextElement().setText("§7You can skip this but some features may not work").setLocation(0.1, 0.15,0.8,0.075).setMaxTextScale(10)); + + this.settingsArea = new SoopyGuiElement().setLocation(0.1, 0.25,0.8,0.75); + this.settingsArea.setScrollable(true) + + this.addChild(this.settingsArea); + } + + load(){ + let y = 0 + + let settings = [this.guiPage.mainThing.apiKeySetting, this.guiPage.mainThing.verifyApiKey, this.guiPage.mainThing.findApiKey, this.guiPage.mainThing.newApiKey] + settings.forEach(setting => { + setting = setting.getGuiObject() + + setting.location.location.y.set(y, 0) + + this.settingsArea.addChild(setting); + + y += 0.045+setting.location.size.y.get() + }) + } +} class HowToOpenMenuPage extends FirstLoadPage{ constructor(){ @@ -59,4 +89,4 @@ class HowToOpenMenuPage extends FirstLoadPage{ } } -export default [new WelcomePage(), new HowToOpenMenuPage()]
\ No newline at end of file +export default [new WelcomePage(), new ApiKeyPage(), new HowToOpenMenuPage()]
\ No newline at end of file diff --git a/features/globalSettings/index.js b/features/globalSettings/index.js index 04e3a20..18a70a3 100644 --- a/features/globalSettings/index.js +++ b/features/globalSettings/index.js @@ -7,6 +7,11 @@ import ToggleSetting from "../settings/settingThings/toggle"; import firstLoadPages from "./firstLoadPages"; import GuiPage from "../soopyGui/GuiPage" import SoopyTextElement from "../../../guimanager/GuiElement/SoopyTextElement"; +import Notification from "../../../guimanager/Notification"; +import logger from "../../logger"; +const Files = Java.type("java.nio.file.Files") +const Paths = Java.type("java.nio.file.Paths") +const JavaString = Java.type("java.lang.String") class Hud extends Feature { constructor() { @@ -23,37 +28,175 @@ class Hud extends Feature { onEnable(){ this.apiKeySetting = new TextSetting("Api Key", "Your hypixel api key", "", "api_key", this, "Run /api new to load", true) this.verifyApiKey = new ButtonSetting("Verify api key", "Click this to make sure the api key is working", "verify_key", this, "Click!", this.verifyKey, undefined) + this.newApiKey = new ButtonSetting("Run /api new", "This is here so u dont need to exit and re-enter", "api_new_command", this, "Click!", this.apiNewCommand, undefined) + this.findApiKey = new ButtonSetting("Attempt to load api key from other mods", "This will scan other mods configs to attempt to find your key", "find_key", this, "Click!", this.findKey, undefined) + this.notifyNewVersion = new ToggleSetting("Notify when there is a new update", "Will notify you when there is a new version of soopyv2 avalible for download", true, "notify_update", this) //TODO: Make false by default when uploaded on ct website - // this.reportErrorsSetting = new ToggleSetting("Send module errors to soopy server", "This will allow me to more effectivly fix them", false, "privacy_send_errors", this) - // this.sendChatSetting = new ToggleSetting("Send (hashed) chat messages to soopy server", "This will allow the hide spam feature to detect messages that are spam", false, "privacy_send_chat", this) + this.reportErrorsSetting = new ToggleSetting("Send module errors to soopy server", "This will allow me to more effectivly fix them", false, "privacy_send_errors", this) + this.sendChatSetting = new ToggleSetting("Send (hashed) chat messages to soopy server", "This will allow the hide spam feature to detect messages that are spam", false, "privacy_send_chat", this) - // this.privacySettings = [this.reportErrorsSetting, this.sendChatSetting] + this.privacySettings = [this.reportErrorsSetting, this.sendChatSetting] - // this.GuiPage = new FirstLoadingPage(this) + this.GuiPage = new FirstLoadingPage(this) this.registerChat("&aYour new API key is &r&b${key}&r", this.newKey) - // new Thread(()=>{ - // Thread.sleep(1000) - // ChatLib.command("soopyv2 first_load_thing", true)//TODO: ONLY RUN ON FIRST INSTALL - // }).start() + new Thread(()=>{ + Thread.sleep(1000) //TODO: DO ON WORLDLOAD + ChatLib.command("soopyv2 first_load_thing", true)//TODO: ONLY RUN ON FIRST INSTALL + }).start() } - verifyKey(){ + findKey(){ + function verifyKey(key){ + // console.log(key) + if(key){ + try{ + var url = "https://api.hypixel.net/key?key=" + key + let data = JSON.parse(FileLib.getUrlContent(url)) + + // console.log(data) + + if(data.success){ + return true + }else{ + return false + } + }catch(e){ + return false + } + }else{ + return false + } + } + new Notification("Finding key...", []) + new Thread(()=>{ + + // NEU + try{ + let testKey = JSON.parse(new JavaString(Files.readAllBytes(Paths.get("./config/notenoughupdates/configNew.json")))).apiKey.apiKey + if(testKey){ + if(verifyKey(testKey)){ + this.module.apiKeySetting.setValue(testKey) + new Notification("§aSuccess!", ["Found api key in NotEnoughUpdates!"]) + return; + }else{ + logger.logMessage("Found invalid key in NotEnoughUpdates", 3) + } + } + }catch(_){} + + // SBE + // try{ + let testKey = JSON.parse(new JavaString(Files.readAllBytes(Paths.get("./config/SkyblockExtras.cfg")))).values.apiKey + if(testKey){ + if(verifyKey(testKey)){ + this.module.apiKeySetting.setValue(testKey) + new Notification("§aSuccess!", ["Found api key in SkyblockExtras!"]) + return; + }else{ + logger.logMessage("Found invalid key in SkyblockExtras", 3) + } + } + // }catch(_){} + // SKYTILS + try{ + let testKey2 = new JavaString(Files.readAllBytes(Paths.get("./config/skytils/config.toml"))) + let testKey = undefined + testKey2.split("\n").forEach(line=>{ + if(line.startsWith(" hypixel_api_key = \"")){ + testKey = line.split("\"")[1] + } + }) + if(testKey){ + if(verifyKey(testKey)){ + this.module.apiKeySetting.setValue(testKey) + new Notification("§aSuccess!", ["Found api key in Skytils!"]) + return; + }else{ + logger.logMessage("Found invalid key in Skytils", 3) + } + } + }catch(_){} + + // SOOPYADDONS DATA + try{ + let testKey = FileLib.read("soopyAddonsData", "apikey.txt") + if(testKey){ + if(verifyKey(testKey)){ + this.module.apiKeySetting.setValue(testKey) + new Notification("§aSuccess!", ["Found api key in old soopyaddons version!"]) + return; + }else{ + logger.logMessage("Found invalid key in soopyaddonsData", 3) + } + } + }catch(_){} + + // HypixelApiKeyManager + try{ + let testKey = JSON.parse(FileLib.read("HypixelApiKeyManager", "localdata.json")).key + if(testKey){ + if(verifyKey(testKey)){ + this.module.apiKeySetting.setValue(testKey) + new Notification("§aSuccess!", ["Found api key in HypixelApiKeyManager!"]) + return; + }else{ + logger.logMessage("Found invalid key in HypixelApiKeyManager", 3) + } + } + }catch(_){} + }).start() + } + + apiNewCommand(){ + ChatLib.command("api new") + } + + verifyKey(key){ + if(key){ + try{ + var url = "https://api.hypixel.net/key?key=" + key + let data = JSON.parse(FileLib.getUrlContent(url)) + + if(data.success){ + return true + }else{ + return false + } + }catch(e){ + return false + } + } if(this.module.apiKeySetting.getValue() == ""){ - ChatLib.chat("&c[SOOPY V2] You need to set an api key first!") + new Notification("§cError!", ["You need to set an api key first!"]) return } - var url = "https://api.hypixel.net/key?key=" + this.module.apiKeySetting.getValue() - ChatLib.chat("&c[SOOPY V2] The rest of checking is yet to be coded!") + new Thread(()=>{ + try{ + var url = "https://api.hypixel.net/key?key=" + this.module.apiKeySetting.getValue() + let data = JSON.parse(FileLib.getUrlContent(url)) + + if(data.success){ + new Notification("§aSuccess!", ["Your api key is valid!"]) + return + }else{ + new Notification("§cError!", ["Your api key is invalid!"]) + return + } + }catch(e){ + new Notification("§cError!", ["Your api key is invalid!"]) + return + } + }).start() } - newKey(key){ + newKey(key, event){ ChatLib.chat("&c[SOOPY V2] Copied api key!") this.apiKeySetting.setValue(key) } diff --git a/features/settings/index.js b/features/settings/index.js index 6d41754..6aac1fa 100644 --- a/features/settings/index.js +++ b/features/settings/index.js @@ -147,7 +147,7 @@ class SettingPage extends GuiPage { let isHidden = meta.isHidden if(typeof isHidden === "string"){ - isHidden = require("../" + f + "/" + isHidden).default() + isHidden = require("../" + f + "/" + isHidden).hidden(this.FeatureManager) } if(isHidden) return |