diff options
author | Lorenz <ESs95s3P5z8Pheb> | 2022-07-14 11:13:53 +0200 |
---|---|---|
committer | Lorenz <ESs95s3P5z8Pheb> | 2022-07-14 11:13:53 +0200 |
commit | b2108f37f551fba5cb43f4919d69e5db7bb1e44c (patch) | |
tree | 04efb1b7815e2e8625ed00810bee711ca2a132a7 /src/main/java/at/lorenz/mod/utils | |
parent | 26c36ab5f0135b50dbe0a983023d80504e2f66b4 (diff) | |
download | skyhanni-b2108f37f551fba5cb43f4919d69e5db7bb1e44c.tar.gz skyhanni-b2108f37f551fba5cb43f4919d69e5db7bb1e44c.tar.bz2 skyhanni-b2108f37f551fba5cb43f4919d69e5db7bb1e44c.zip |
remove old skytils code
Diffstat (limited to 'src/main/java/at/lorenz/mod/utils')
-rw-r--r-- | src/main/java/at/lorenz/mod/utils/APIUtil.kt | 70 | ||||
-rw-r--r-- | src/main/java/at/lorenz/mod/utils/RenderUtils.kt | 2 |
2 files changed, 2 insertions, 70 deletions
diff --git a/src/main/java/at/lorenz/mod/utils/APIUtil.kt b/src/main/java/at/lorenz/mod/utils/APIUtil.kt index 88d459ada..7e0193f50 100644 --- a/src/main/java/at/lorenz/mod/utils/APIUtil.kt +++ b/src/main/java/at/lorenz/mod/utils/APIUtil.kt @@ -1,6 +1,5 @@ package at.lorenz.mod.utils -import com.google.gson.JsonArray import com.google.gson.JsonObject import com.google.gson.JsonParser import org.apache.http.client.config.RequestConfig @@ -9,34 +8,13 @@ import org.apache.http.impl.client.HttpClientBuilder import org.apache.http.impl.client.HttpClients import org.apache.http.message.BasicHeader import org.apache.http.util.EntityUtils -import scala.util.parsing.json.JSONArray -import scala.util.parsing.json.JSONObject -import java.awt.image.BufferedImage -import java.net.HttpURLConnection -import java.net.URL -import java.security.cert.X509Certificate -import javax.imageio.ImageIO object APIUtil { private val parser = JsonParser() -// val sslContext = SSLContexts.custom() -// .loadTrustMaterial { chain, authType -> -// isValidCert(chain, authType) -// } -// .build() -// val sslSocketFactory = SSLConnectionSocketFactoryBuilder.create() -// .setSslContext(sslContext) -// .build() - -// val cm = PoolingHttpClientConnectionManagerBuilder.create() -// .setSSLSocketFactory(sslSocketFactory) - val builder: HttpClientBuilder = HttpClients.custom().setUserAgent("LorenzMod") -// .setConnectionManagerShared(true) -// .setConnectionManager(cm.build()) .setDefaultHeaders( mutableListOf( BasicHeader("Pragma", "no-cache"), @@ -45,27 +23,10 @@ object APIUtil { ) .setDefaultRequestConfig( RequestConfig.custom() -// .setConnectTimeout(Timeout.ofMinutes(1)) -// .setResponseTimeout(Timeout.ofMinutes(1)) .build() ) .useSystemProperties() - /** - * Taken from Elementa under MIT License - * @link https://github.com/Sk1erLLC/Elementa/blob/master/LICENSE - */ - fun URL.getImage(): BufferedImage { - val connection = this.openConnection() as HttpURLConnection - - connection.requestMethod = "GET" - connection.useCaches = true - connection.addRequestProperty("User-Agent", "LorenzMod") - connection.doOutput = true - - return ImageIO.read(connection.inputStream) - } - fun getJSONResponse(urlString: String): JsonObject { val client = builder.build() try { @@ -74,43 +35,14 @@ object APIUtil { if (entity != null) { val retSrc = EntityUtils.toString(entity) return parser.parse(retSrc) as JsonObject - // parsing JSON -// val result = JSONObject(retSrc) //Convert String to JSON Object -// val tokenList: JSONArray = result.getJSONArray("names") -// val oj: JSONObject = tokenList.getJSONObject(0) -// val token: String = oj.getString("name") } } } catch (ex: Throwable) { ex.printStackTrace() - LorenzUtils.error("Skytils ran into an ${ex::class.simpleName ?: "error"} whilst fetching a resource. See logs for more details.") + LorenzUtils.error("Lorenz Mod ran into an ${ex::class.simpleName ?: "error"} whilst fetching a resource. See logs for more details.") } finally { client.close() } return JsonObject() } - -// fun getArrayResponse(urlString: String): JsonArray { -// val client = builder.build() -// try { -// client.execute(HttpGet(urlString)).use { response -> -//// response.entity.content -// response.entity.content { entity -> -// val obj = parser.parse(EntityUtils.toString(entity)).asJsonArray -// EntityUtils.consume(entity) -// return obj -// } -// } -// } catch (ex: Throwable) { -// LorenzUtils.error("Skytils ran into an ${ex::class.simpleName ?: "error"} whilst fetching a resource. See logs for more details.") -// ex.printStackTrace() -// } finally { -// client.close() -// } -// return JsonArray() -// } - - private fun isValidCert(chain: Array<X509Certificate>, authType: String): Boolean { - return chain.any { it.issuerDN.name == "CN=R3, O=Let's Encrypt, C=US" } - } }
\ No newline at end of file diff --git a/src/main/java/at/lorenz/mod/utils/RenderUtils.kt b/src/main/java/at/lorenz/mod/utils/RenderUtils.kt index 7acd5b42b..2e422ed6a 100644 --- a/src/main/java/at/lorenz/mod/utils/RenderUtils.kt +++ b/src/main/java/at/lorenz/mod/utils/RenderUtils.kt @@ -31,7 +31,7 @@ object RenderUtils { ) } - fun RenderWorldLastEvent.drawSkytilsColor(location: LorenzVec, color: LorenzColor, beacon: Boolean = false) { + fun RenderWorldLastEvent.drawColor(location: LorenzVec, color: LorenzColor, beacon: Boolean = false) { val (viewerX, viewerY, viewerZ) = getViewerPos(partialTicks) val x = location.x - viewerX val y = location.y - viewerY |