From 21e61692d6071c0c43d26936b4474ee85cff1b3d Mon Sep 17 00:00:00 2001 From: Aspw-w <0kcabtuo0@gmail.com> Date: Mon, 1 Apr 2024 13:20:04 +0900 Subject: [PATCH] =?UTF-8?q?java51=E3=81=A7=E3=81=AE=E3=82=A8=E3=83=A9?= =?UTF-8?q?=E3=83=BC=E7=9B=B4=E3=81=9B=E3=81=BE=E3=81=9B=E3=82=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 2 + src/main/java/net/aspw/client/Launch.kt | 14 +-- .../client/auth/account/MicrosoftAccount.kt | 6 +- .../aspw/client/features/api/DiscordRPC.kt | 6 +- .../features/command/impl/ConfigCommand.kt | 22 +---- .../features/module/impl/movement/Jesus.kt | 17 +++- .../module/impl/other/StaffProtection.kt | 8 +- .../features/module/impl/visual/Interface.kt | 4 +- .../net/aspw/client/utils/APIConnecter.kt | 91 +++++++++++++++++++ src/main/java/net/aspw/client/utils/Access.kt | 66 -------------- .../net/aspw/client/utils/URLComponent.kt | 10 ++ .../net/aspw/client/visual/client/GuiInfo.kt | 7 +- .../aspw/client/visual/client/GuiMainMenu.kt | 10 +- .../client/altmanager/menus/GuiAddAccount.kt | 3 +- 14 files changed, 149 insertions(+), 117 deletions(-) create mode 100644 src/main/java/net/aspw/client/utils/APIConnecter.kt delete mode 100644 src/main/java/net/aspw/client/utils/Access.kt create mode 100644 src/main/java/net/aspw/client/utils/URLComponent.kt diff --git a/build.gradle b/build.gradle index c8b0a171..f6c179fb 100644 --- a/build.gradle +++ b/build.gradle @@ -65,6 +65,8 @@ dependencies { exclude module: "log4j-core" } + include "com.squareup.okhttp3:okhttp:4.9.1" + for (final def via in viaLibs) { include(via) } diff --git a/src/main/java/net/aspw/client/Launch.kt b/src/main/java/net/aspw/client/Launch.kt index b0f6510b..d0d7fdb6 100644 --- a/src/main/java/net/aspw/client/Launch.kt +++ b/src/main/java/net/aspw/client/Launch.kt @@ -22,9 +22,9 @@ import net.aspw.client.protocol.ProtocolMod import net.aspw.client.utils.* import net.aspw.client.utils.ClassUtils.hasForge import net.aspw.client.utils.misc.sound.TipSoundManager +import net.aspw.client.utils.APIConnecter import net.aspw.client.visual.client.clickgui.dropdown.ClickGui import net.aspw.client.visual.font.semi.Fonts -import net.minecraft.util.ResourceLocation object Launch { @@ -33,12 +33,7 @@ object Launch { const val CLIENT_FOLDER = "NightX-Client" const val CLIENT_VERSION = "B102" const val CLIENT_PROTOCOL_RANGE = "1.8 to 1.20.5" - const val CLIENT_WEBSITE = "https://aspw-w.github.io/AspieAPI/NightX" const val CLIENT_CHAT = "§c$CLIENT_BEST: §r" - const val CLIENT_STATUS = "$CLIENT_WEBSITE/database/data.txt" - const val CLIENT_STAFFS = "$CLIENT_WEBSITE/database/staffs.txt" - const val CLIENT_CONFIGLIST = "$CLIENT_WEBSITE/configs/str/list.txt" - const val CLIENT_CONFIGS = "$CLIENT_WEBSITE/configs/" var isStarting = false @@ -51,9 +46,6 @@ object Launch { lateinit var clickGui: ClickGui - // Menu Background - var background: ResourceLocation? = null - private var lastTick: Long = 0L private var javaVersion = @@ -76,8 +68,8 @@ object Launch { ProtocolBase.init(ProtocolMod.PLATFORM) // Check update - Access.checkStaffList() - Access.checkStatus() + APIConnecter.checkStaffList() + APIConnecter.checkStatus() // Create file manager fileManager = FileManager() diff --git a/src/main/java/net/aspw/client/auth/account/MicrosoftAccount.kt b/src/main/java/net/aspw/client/auth/account/MicrosoftAccount.kt index bab7de96..7d41fc06 100644 --- a/src/main/java/net/aspw/client/auth/account/MicrosoftAccount.kt +++ b/src/main/java/net/aspw/client/auth/account/MicrosoftAccount.kt @@ -10,7 +10,7 @@ import net.aspw.client.auth.utils.HttpUtils import net.aspw.client.auth.utils.array import net.aspw.client.auth.utils.obj import net.aspw.client.auth.utils.string -import net.aspw.client.utils.Access +import net.aspw.client.utils.APIConnecter class MicrosoftAccount : MinecraftAccount("Microsoft") { override var name = "UNKNOWN" @@ -235,8 +235,8 @@ class MicrosoftAccount : MinecraftAccount("Microsoft") { "" ) val AZURE_APP = AuthMethod( - Access.appClientID, - Access.appClientSecret, + APIConnecter.appClientID, + APIConnecter.appClientSecret, "http://localhost:1919/login", "XboxLive.signin%20offline_access", "d=" diff --git a/src/main/java/net/aspw/client/features/api/DiscordRPC.kt b/src/main/java/net/aspw/client/features/api/DiscordRPC.kt index 0789384e..edd117db 100644 --- a/src/main/java/net/aspw/client/features/api/DiscordRPC.kt +++ b/src/main/java/net/aspw/client/features/api/DiscordRPC.kt @@ -5,7 +5,7 @@ import com.jagrosh.discordipc.IPCListener import com.jagrosh.discordipc.entities.RichPresence import com.jagrosh.discordipc.entities.pipe.PipeStatus import net.aspw.client.Launch -import net.aspw.client.utils.Access +import net.aspw.client.utils.APIConnecter import net.aspw.client.utils.ClientUtils import net.aspw.client.utils.MinecraftInstance import org.json.JSONObject @@ -87,7 +87,7 @@ class DiscordRPC : MinecraftInstance() { // Set display infos builder.setDetails(Launch.CLIENT_VERSION) - builder.setState(Access.discord) + builder.setState(APIConnecter.discord) // Check ipc client is connected and send rpc if (ipcClient?.status == PipeStatus.CONNECTED) @@ -110,7 +110,7 @@ class DiscordRPC : MinecraftInstance() { } private fun loadConfiguration() { - appID = Access.discordApp.toLong() + appID = APIConnecter.discordApp.toLong() assets["rpc"] = "rpc" } } \ No newline at end of file diff --git a/src/main/java/net/aspw/client/features/command/impl/ConfigCommand.kt b/src/main/java/net/aspw/client/features/command/impl/ConfigCommand.kt index a5ca6092..1cef2f73 100644 --- a/src/main/java/net/aspw/client/features/command/impl/ConfigCommand.kt +++ b/src/main/java/net/aspw/client/features/command/impl/ConfigCommand.kt @@ -3,7 +3,9 @@ package net.aspw.client.features.command.impl import net.aspw.client.Launch import net.aspw.client.features.command.Command import net.aspw.client.features.module.impl.visual.Interface +import net.aspw.client.utils.APIConnecter import net.aspw.client.utils.SettingsUtils +import net.aspw.client.utils.URLComponent import net.aspw.client.utils.misc.StringUtils import org.apache.http.client.methods.HttpGet import org.apache.http.impl.client.CloseableHttpClient @@ -46,15 +48,7 @@ class ConfigCommand : Command("config", arrayOf("c")) { args[1].equals("onlineload", ignoreCase = true) -> { if (args.size > 2) { try { - val httpClient: CloseableHttpClient = HttpClients.createDefault() - val request = HttpGet(Launch.CLIENT_CONFIGS + args[2]) - val response = httpClient.execute(request) - val entity = response.entity - val content = EntityUtils.toString(entity) - EntityUtils.consume(entity) - response.close() - httpClient.close() - SettingsUtils.executeScript(content) + SettingsUtils.executeScript(APIConnecter.configLoad(args[2])) if (Launch.moduleManager.getModule(Interface::class.java)?.flagSoundValue!!.get()) { Launch.tipSoundManager.popSound.asyncPlay(Launch.moduleManager.popSoundPower) } @@ -178,16 +172,8 @@ class ConfigCommand : Command("config", arrayOf("c")) { args[1].equals("onlinelist", ignoreCase = true) -> { try { - val httpClient: CloseableHttpClient = HttpClients.createDefault() - val request = HttpGet(Launch.CLIENT_CONFIGLIST) - val response = httpClient.execute(request) - val entity = response.entity - val content = EntityUtils.toString(entity) - EntityUtils.consume(entity) - response.close() - httpClient.close() chat("§cOnlineConfigs:") - chat(content) + chat(APIConnecter.configList()) } catch (e: Exception) { chat("§cAPI Error!") } diff --git a/src/main/java/net/aspw/client/features/module/impl/movement/Jesus.kt b/src/main/java/net/aspw/client/features/module/impl/movement/Jesus.kt index b93e0886..2317c52d 100644 --- a/src/main/java/net/aspw/client/features/module/impl/movement/Jesus.kt +++ b/src/main/java/net/aspw/client/features/module/impl/movement/Jesus.kt @@ -35,7 +35,9 @@ class Jesus : Module() { "MatrixFast", "MatrixDolphin", "Dolphin", - "Swim" + "Swim", + "Vulcan", + "Verus" ), "NCP" ) @@ -77,6 +79,19 @@ class Jesus : Module() { if (mc.thePlayer.hurtTime != 0) mc.thePlayer.onGround = false } + "verus" -> if (mc.thePlayer.isInWater) { + mc.thePlayer.motionY = 0.0 + MovementUtils.strafe(0.32f) + } + + "vulcan" -> if (mc.thePlayer.isInWater) { + mc.thePlayer.motionY = 0.015 * + if (!MovementUtils.isMoving()) 0 + else if (mc.thePlayer.ticksExisted % 2 == 0) 1 + else -1 + MovementUtils.strafe(0.145f) + } + "matrixfast" -> if (mc.thePlayer.isInWater) { mc.thePlayer.motionY = 0.0 MovementUtils.strafe(0.6f) diff --git a/src/main/java/net/aspw/client/features/module/impl/other/StaffProtection.kt b/src/main/java/net/aspw/client/features/module/impl/other/StaffProtection.kt index 32469cb4..5be8b891 100644 --- a/src/main/java/net/aspw/client/features/module/impl/other/StaffProtection.kt +++ b/src/main/java/net/aspw/client/features/module/impl/other/StaffProtection.kt @@ -7,7 +7,7 @@ import net.aspw.client.event.WorldEvent import net.aspw.client.features.module.Module import net.aspw.client.features.module.ModuleCategory import net.aspw.client.features.module.ModuleInfo -import net.aspw.client.utils.Access +import net.aspw.client.utils.APIConnecter import net.aspw.client.utils.EntityUtils import net.aspw.client.utils.render.ColorUtils import net.aspw.client.value.BoolValue @@ -41,9 +41,9 @@ class StaffProtection : Module() { override fun onEnable() { thread { totalCount = obStaffs.count { it.isWhitespace() } - blocksmcstaffs.addAll(Access.bmcstafflist.split(",")) - mushmcstaffs.addAll(Access.mushstafflist.split(",")) - hypixelstaffs.addAll(Access.hypixelstafflist.split(",")) + blocksmcstaffs.addAll(APIConnecter.bmcstafflist.split(",")) + mushmcstaffs.addAll(APIConnecter.mushstafflist.split(",")) + hypixelstaffs.addAll(APIConnecter.hypixelstafflist.split(",")) } detected = false staffsInWorld.clear() diff --git a/src/main/java/net/aspw/client/features/module/impl/visual/Interface.kt b/src/main/java/net/aspw/client/features/module/impl/visual/Interface.kt index 1fc6120d..497872df 100644 --- a/src/main/java/net/aspw/client/features/module/impl/visual/Interface.kt +++ b/src/main/java/net/aspw/client/features/module/impl/visual/Interface.kt @@ -12,7 +12,7 @@ import net.aspw.client.features.module.impl.combat.KillAura import net.aspw.client.features.module.impl.combat.KillAuraRecode import net.aspw.client.features.module.impl.combat.TPAura import net.aspw.client.protocol.ProtocolBase -import net.aspw.client.utils.Access +import net.aspw.client.utils.APIConnecter import net.aspw.client.utils.AnimationUtils import net.aspw.client.utils.render.ColorUtils import net.aspw.client.utils.render.RenderUtils @@ -88,7 +88,7 @@ class Interface : Module() { try { if (watermarkValue.get()) { val inputString = clientNameValue.get() - val connectChecks = if (!Access.canConnect) " - Disconnected" else "" + val connectChecks = if (!APIConnecter.canConnect) " - Disconnected" else "" val fpsChecks = if (watermarkFpsValue.get()) " [" + Minecraft.getDebugFPS() + " FPS]" else "" val protocolChecks = if (watermarkProtocolValue.get()) " [version: " + (if (!mc.isIntegratedServerRunning) ProtocolBase.getManager().targetVersion.name else "1.8.x") + "]" else "" diff --git a/src/main/java/net/aspw/client/utils/APIConnecter.kt b/src/main/java/net/aspw/client/utils/APIConnecter.kt new file mode 100644 index 00000000..0b2b963c --- /dev/null +++ b/src/main/java/net/aspw/client/utils/APIConnecter.kt @@ -0,0 +1,91 @@ +package net.aspw.client.utils + +import net.aspw.client.Launch +import okhttp3.* + +object APIConnecter { + + var canConnect = false + var isLatest = false + var discord = "" + var discordApp = "" + var appClientID = "" + var appClientSecret = "" + var bmcstafflist = "" + var mushstafflist = "" + var hypixelstafflist = "" + + fun checkStatus() { + try { + var gotData: String + val client = OkHttpClient() + val builder = Request.Builder().url(URLComponent.STATUS) + val request: Request = builder.build() + client.newCall(request).execute().use { response -> + gotData = response.body!!.string() + } + val details = gotData.split("///") + isLatest = details[4] == Launch.CLIENT_VERSION + discord = details[3] + discordApp = details[2] + appClientSecret = details[1] + appClientID = details[0] + canConnect = true + ClientUtils.getLogger().info("Loaded API") + } catch (e: Exception) { + canConnect = false + ClientUtils.getLogger().info("Failed to load API") + } + } + + fun checkStaffList() { + try { + var gotData: String + val client = OkHttpClient() + val builder = Request.Builder().url(URLComponent.STAFFS) + val request: Request = builder.build() + client.newCall(request).execute().use { response -> + gotData = response.body!!.string() + } + val details = gotData.split("-") + bmcstafflist = details[0] + mushstafflist = details[1] + hypixelstafflist = details[2] + ClientUtils.getLogger().info("Loaded Staff List") + } catch (e: Exception) { + ClientUtils.getLogger().info("Failed to load Staff List") + } + } + + fun configLoad(name: String): String { + var gotData = "" + try { + val client = OkHttpClient() + val builder = Request.Builder().url(URLComponent.CONFIGS + name) + val request: Request = builder.build() + client.newCall(request).execute().use { response -> + gotData = response.body!!.string() + } + ClientUtils.getLogger().info("Loaded Config Data") + } catch (e: Exception) { + ClientUtils.getLogger().info("Failed to load Config Data") + } + return gotData + } + + fun configList(): String { + var gotData = "" + try { + val client = OkHttpClient() + val builder = Request.Builder().url(URLComponent.CONFIGLIST) + val request: Request = builder.build() + client.newCall(request).execute().use { response -> + gotData = response.body!!.string() + } + ClientUtils.getLogger().info("Loaded Config List") + } catch (e: Exception) { + ClientUtils.getLogger().info("Failed to load Config List") + } + return gotData + } +} \ No newline at end of file diff --git a/src/main/java/net/aspw/client/utils/Access.kt b/src/main/java/net/aspw/client/utils/Access.kt deleted file mode 100644 index 7109f793..00000000 --- a/src/main/java/net/aspw/client/utils/Access.kt +++ /dev/null @@ -1,66 +0,0 @@ -package net.aspw.client.utils - -import net.aspw.client.Launch -import org.apache.http.client.methods.HttpGet -import org.apache.http.impl.client.CloseableHttpClient -import org.apache.http.impl.client.HttpClients -import org.apache.http.util.EntityUtils - -object Access { - - var canConnect = false - var isLatest = false - var clientGithub = "" - var discord = "" - var discordApp = "" - var appClientID = "" - var appClientSecret = "" - var bmcstafflist = "" - var mushstafflist = "" - var hypixelstafflist = "" - - fun checkStaffList() { - try { - val httpClient: CloseableHttpClient = HttpClients.createDefault() - val request = HttpGet(Launch.CLIENT_STAFFS) - val response = httpClient.execute(request) - val entity = response.entity - val content = EntityUtils.toString(entity) - EntityUtils.consume(entity) - response.close() - httpClient.close() - val details = content.split("-") - bmcstafflist = details[0] - mushstafflist = details[1] - hypixelstafflist = details[2] - ClientUtils.getLogger().info("Loaded Staff List") - } catch (e: Exception) { - ClientUtils.getLogger().info("Failed to load Staff List") - } - } - - fun checkStatus() { - try { - val httpClient: CloseableHttpClient = HttpClients.createDefault() - val request = HttpGet(Launch.CLIENT_STATUS) - val response = httpClient.execute(request) - val entity = response.entity - val content = EntityUtils.toString(entity) - EntityUtils.consume(entity) - response.close() - httpClient.close() - val details = content.split("///") - isLatest = details[5] == Launch.CLIENT_VERSION - clientGithub = details[4] - discord = details[3] - discordApp = details[2] - appClientSecret = details[1] - appClientID = details[0] - canConnect = true - ClientUtils.getLogger().info("Loaded API") - } catch (e: Exception) { - canConnect = false - ClientUtils.getLogger().info("Failed to load API") - } - } -} \ No newline at end of file diff --git a/src/main/java/net/aspw/client/utils/URLComponent.kt b/src/main/java/net/aspw/client/utils/URLComponent.kt new file mode 100644 index 00000000..72e8d5e6 --- /dev/null +++ b/src/main/java/net/aspw/client/utils/URLComponent.kt @@ -0,0 +1,10 @@ +package net.aspw.client.utils + +object URLComponent { + const val WEBSITE = "https://aspw-w.github.io/NightX" //Pastebinだとエラー出ない GitHubSitesでやるとJava1.8.0_51でエラー + const val STATUS = "$WEBSITE/database/data.txt" + const val STAFFS = "$WEBSITE/database/staffs.txt" + const val CONFIGLIST = "$WEBSITE/configs/str/list.txt" + const val CONFIGS = "$WEBSITE/configs/" + const val JAVAUPDATE = "https://www.java.com/download" +} \ No newline at end of file diff --git a/src/main/java/net/aspw/client/visual/client/GuiInfo.kt b/src/main/java/net/aspw/client/visual/client/GuiInfo.kt index 83057b1d..f4107eb2 100644 --- a/src/main/java/net/aspw/client/visual/client/GuiInfo.kt +++ b/src/main/java/net/aspw/client/visual/client/GuiInfo.kt @@ -1,7 +1,8 @@ package net.aspw.client.visual.client import net.aspw.client.Launch -import net.aspw.client.utils.Access +import net.aspw.client.utils.APIConnecter +import net.aspw.client.utils.URLComponent import net.aspw.client.utils.misc.MiscUtils import net.aspw.client.utils.render.RenderUtils import net.minecraft.client.gui.GuiButton @@ -40,8 +41,8 @@ class GuiInfo(private val prevGui: GuiScreen) : GuiScreen() { override fun actionPerformed(button: GuiButton) { when (button.id) { - 1 -> MiscUtils.showURL(Launch.CLIENT_WEBSITE) - 2 -> MiscUtils.showURL(Access.discord) + 1 -> MiscUtils.showURL(URLComponent.WEBSITE) + 2 -> MiscUtils.showURL(APIConnecter.discord) 3 -> mc.displayGuiScreen(GuiModList(this)) 4 -> mc.displayGuiScreen(prevGui) } diff --git a/src/main/java/net/aspw/client/visual/client/GuiMainMenu.kt b/src/main/java/net/aspw/client/visual/client/GuiMainMenu.kt index dc1819b7..80dda920 100644 --- a/src/main/java/net/aspw/client/visual/client/GuiMainMenu.kt +++ b/src/main/java/net/aspw/client/visual/client/GuiMainMenu.kt @@ -1,7 +1,7 @@ package net.aspw.client.visual.client import net.aspw.client.Launch -import net.aspw.client.utils.Access +import net.aspw.client.utils.APIConnecter import net.aspw.client.utils.render.RenderUtils import net.aspw.client.visual.client.altmanager.GuiAltManager import net.aspw.client.visual.font.smooth.FontLoaders @@ -105,7 +105,7 @@ class GuiMainMenu : GuiScreen(), GuiYesNoCallback { width, height ) GlStateManager.enableAlpha() - if (Access.canConnect) { + if (APIConnecter.canConnect) { FontLoaders.SF20.drawStringWithShadow( "API Connection: §eOK", (this.width - 10F - FontLoaders.SF20.getStringWidth("API Connection: §eOK")).toDouble(), @@ -139,7 +139,7 @@ class GuiMainMenu : GuiScreen(), GuiYesNoCallback { -1 ) val uiMessage = - if (Access.canConnect && Access.isLatest) " §e(Latest)" else if (!Access.canConnect && Access.isLatest) " §c(API Dead)" else " §c(Outdated)" + if (APIConnecter.canConnect && APIConnecter.isLatest) " §e(Latest)" else if (!APIConnecter.canConnect && APIConnecter.isLatest) " §c(API Dead)" else " §c(Outdated)" FontLoaders.SF20.drawStringWithShadow( "Your currently build is " + Launch.CLIENT_VERSION + uiMessage, width - 4F - FontLoaders.SF20.getStringWidth("Your currently build is " + Launch.CLIENT_VERSION + uiMessage) @@ -163,8 +163,8 @@ class GuiMainMenu : GuiScreen(), GuiYesNoCallback { 5 -> mc.displayGuiScreen(GuiInfo(this)) 6 -> { - Access.checkStatus() - Access.checkStaffList() + APIConnecter.checkStatus() + APIConnecter.checkStaffList() } } } diff --git a/src/main/java/net/aspw/client/visual/client/altmanager/menus/GuiAddAccount.kt b/src/main/java/net/aspw/client/visual/client/altmanager/menus/GuiAddAccount.kt index 85e00876..5bc5e7a3 100644 --- a/src/main/java/net/aspw/client/visual/client/altmanager/menus/GuiAddAccount.kt +++ b/src/main/java/net/aspw/client/visual/client/altmanager/menus/GuiAddAccount.kt @@ -3,6 +3,7 @@ package net.aspw.client.visual.client.altmanager.menus import net.aspw.client.Launch import net.aspw.client.auth.account.CrackedAccount import net.aspw.client.features.module.impl.visual.Interface +import net.aspw.client.utils.URLComponent import net.aspw.client.utils.misc.MiscUtils import net.aspw.client.utils.render.RenderUtils import net.aspw.client.visual.client.altmanager.GuiAltManager @@ -85,7 +86,7 @@ class GuiAddAccount(private val prevGui: GuiAltManager) : GuiScreen() { 3 -> mc.displayGuiScreen(GuiMicrosoftLogin(this)) - 4 -> MiscUtils.showURL("https://www.oracle.com/jp/java/technologies/javase/javase8-archive-downloads.html") + 4 -> MiscUtils.showURL(URLComponent.JAVAUPDATE) } }