Skip to content

Commit 4e860a8

Browse files
committed
Fix build and address deprecation warnings
1 parent 1a7c78f commit 4e860a8

File tree

5 files changed

+37
-61
lines changed

5 files changed

+37
-61
lines changed

build.gradle.kts

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
import org.cadixdev.gradle.licenser.header.HeaderStyle
1212
import org.gradle.internal.jvm.Jvm
13-
import org.gradle.internal.os.OperatingSystem
1413
import org.jetbrains.gradle.ext.settings
1514
import org.jetbrains.gradle.ext.taskTriggers
1615
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
@@ -22,7 +21,7 @@ plugins {
2221
mcdev
2322
groovy
2423
idea
25-
id("org.jetbrains.intellij") version "1.9.0"
24+
id("org.jetbrains.intellij") version "1.12.0"
2625
id("org.cadixdev.licenser")
2726
id("org.jlleitschuh.gradle.ktlint") version "10.3.0"
2827
}
@@ -247,22 +246,6 @@ tasks.test {
247246
jvmArgs(
248247
"-Dsun.io.useCanonCaches=false",
249248
"-Dsun.io.useCanonPrefixCache=false",
250-
"--add-opens", "java.base/java.io=ALL-UNNAMED",
251-
"--add-opens", "java.base/java.lang.invoke=ALL-UNNAMED",
252-
"--add-opens", "java.base/java.lang.ref=ALL-UNNAMED",
253-
"--add-opens", "java.base/java.lang.reflect=ALL-UNNAMED",
254-
"--add-opens", "java.base/java.lang=ALL-UNNAMED",
255-
"--add-opens", "java.base/java.util.concurrent.atomic=ALL-UNNAMED",
256-
"--add-opens", "java.base/java.util.concurrent.locks=ALL-UNNAMED",
257-
"--add-opens", "java.base/java.util.concurrent=ALL-UNNAMED",
258-
"--add-opens", "java.base/sun.nio.fs=ALL-UNNAMED",
259-
"--add-opens", "java.desktop/java.awt.event=ALL-UNNAMED",
260-
"--add-opens", "java.desktop/java.awt=ALL-UNNAMED",
261-
"--add-opens", "java.desktop/javax.swing.plaf.basic=ALL-UNNAMED",
262-
"--add-opens", "java.desktop/javax.swing=ALL-UNNAMED",
263-
"--add-opens", "java.desktop/sun.awt=ALL-UNNAMED",
264-
"--add-opens", "java.desktop/sun.font=ALL-UNNAMED",
265-
"--add-opens", "java.desktop/sun.swing=ALL-UNNAMED",
266249
)
267250
}
268251

@@ -379,22 +362,4 @@ tasks.runIde {
379362
tasks.buildSearchableOptions {
380363
// not working atm
381364
enabled = false
382-
// https://youtrack.jetbrains.com/issue/IDEA-210683
383-
jvmArgs(
384-
"--illegal-access=deny",
385-
"--add-exports=java.base/jdk.internal.vm=ALL-UNNAMED",
386-
"--add-opens=java.base/java.lang=ALL-UNNAMED",
387-
"--add-opens=java.base/java.util=ALL-UNNAMED",
388-
"--add-opens=java.desktop/java.awt.event=ALL-UNNAMED",
389-
"--add-opens=java.desktop/java.awt=ALL-UNNAMED",
390-
"--add-opens=java.desktop/javax.swing.plaf.basic=ALL-UNNAMED",
391-
"--add-opens=java.desktop/javax.swing=ALL-UNNAMED",
392-
"--add-opens=java.desktop/sun.awt=ALL-UNNAMED",
393-
"--add-opens=java.desktop/sun.font=ALL-UNNAMED",
394-
"--add-opens=java.desktop/sun.swing=ALL-UNNAMED"
395-
)
396-
397-
if (OperatingSystem.current().isMacOsX) {
398-
jvmArgs("--add-opens=java.desktop/com.apple.eawt.event=ALL-UNNAMED")
399-
}
400365
}

src/main/kotlin/creator/PlatformVersion.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import kotlin.reflect.KClass
2929
private const val CLOUDFLARE_BASE_URL = "https://minecraftdev.org/versions/"
3030
private const val GITHUB_BASE_URL = "https://raw.githubusercontent.com/minecraft-dev/minecraftdev.org/master/versions/"
3131

32-
val PLATFORM_VERSION_LOGGER = Logger.getInstance("MDev.PlatformVersion")
32+
val PLATFORM_VERSION_LOGGER = Logger.getInstance("com.demonwav.mcdev.creator.PlatformVersion")
3333

3434
suspend fun getVersionSelector(type: PlatformType): PlatformVersion {
3535
val versionJson = type.versionJson ?: throw UnsupportedOperationException("Incorrect platform type: $type")

src/main/kotlin/platform/architectury/version/ArchitecturyVersion.kt

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -45,36 +45,41 @@ class ArchitecturyVersion private constructor(
4545

4646
companion object {
4747

48-
suspend fun downloadData(): ArchitecturyVersion {
49-
val url = "https://api.modrinth.com/v2/project/architectury-api/version"
50-
val manager = FuelManager()
51-
manager.proxy = selectProxy(url)
48+
suspend fun downloadData(): ArchitecturyVersion? {
49+
try {
50+
val url = "https://api.modrinth.com/v2/project/architectury-api/version"
51+
val manager = FuelManager()
52+
manager.proxy = selectProxy(url)
5253

53-
val response = manager.get(url)
54-
.header("User-Agent", PluginUtil.useragent)
55-
.suspendable()
56-
.awaitString()
54+
val response = manager.get(url)
55+
.header("User-Agent", PluginUtil.useragent)
56+
.suspendable()
57+
.awaitString()
5758

58-
val data = Gson().fromJson<List<ModrinthVersionApi>>(response)
59+
val data = Gson().fromJson<List<ModrinthVersionApi>>(response)
5960

60-
val apiVersionMap = HashMap<SemanticVersion, HashSet<SemanticVersion>>()
61+
val apiVersionMap = HashMap<SemanticVersion, HashSet<SemanticVersion>>()
6162

62-
for (version in data) {
63-
val apiVersion = SemanticVersion.parse(version.versionNumber.substringBeforeLast('+'))
63+
for (version in data) {
64+
val apiVersion = SemanticVersion.parse(version.versionNumber.substringBeforeLast('+'))
6465

65-
for (gameVersion in version.gameVersions) {
66-
val parsed = SemanticVersion.parse(gameVersion)
67-
val set = apiVersionMap.computeIfAbsent(parsed) { HashSet() }
68-
set += apiVersion
66+
for (gameVersion in version.gameVersions) {
67+
val parsed = SemanticVersion.parse(gameVersion)
68+
val set = apiVersionMap.computeIfAbsent(parsed) { HashSet() }
69+
set += apiVersion
70+
}
6971
}
70-
}
7172

72-
val apiVersionMapList = HashMap<SemanticVersion, List<SemanticVersion>>()
73-
for ((mcVersion, archList) in apiVersionMap.entries) {
74-
apiVersionMapList[mcVersion] = archList.sortedDescending()
75-
}
73+
val apiVersionMapList = HashMap<SemanticVersion, List<SemanticVersion>>()
74+
for ((mcVersion, archList) in apiVersionMap.entries) {
75+
apiVersionMapList[mcVersion] = archList.sortedDescending()
76+
}
7677

77-
return ArchitecturyVersion(apiVersionMapList)
78+
return ArchitecturyVersion(apiVersionMapList)
79+
} catch (e: IOException) {
80+
e.printStackTrace()
81+
}
82+
return null
7883
}
7984
}
8085
}

src/main/kotlin/platform/mixin/handlers/injectionPoint/LoadInjectionPoint.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,9 @@ abstract class AbstractLoadInjectionPoint(private val store: Boolean) : Injectio
180180
override fun visitForeachStatement(statement: PsiForeachStatement) {
181181
checkImplicitLocalsPre(statement)
182182
if (store) {
183-
addLocalUsage(statement.iterationParameter, statement.iterationParameter.name)
183+
(statement.iterationDeclaration as? PsiParameter)?.let { param ->
184+
addLocalUsage(param, param.name)
185+
}
184186
}
185187
super.visitForeachStatement(statement)
186188
checkImplicitLocalsPost(statement)

src/main/kotlin/platform/mixin/util/LocalVariables.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ import com.intellij.psi.PsiForeachStatement
5555
import com.intellij.psi.PsiLambdaExpression
5656
import com.intellij.psi.PsiMethod
5757
import com.intellij.psi.PsiModifier
58+
import com.intellij.psi.PsiParameter
5859
import com.intellij.psi.PsiStatement
5960
import com.intellij.psi.PsiType
6061
import com.intellij.psi.PsiVariable
@@ -299,7 +300,10 @@ object LocalVariables {
299300
// longs and doubles take two slots
300301
is PsiVariable -> if (element.isDoubleSlot) 2 else 1
301302
// arrays have copy of array, length and index variables, iterables have the iterator variable
302-
is PsiForeachStatement -> if (element.iterationParameter.type is PsiArrayType) 3 else 1
303+
is PsiForeachStatement -> {
304+
val param = element.iterationDeclaration as? PsiParameter
305+
if (param?.type is PsiArrayType) 3 else 1
306+
}
303307
else -> 0
304308
}
305309
}

0 commit comments

Comments
 (0)